Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

How to center an image on a page

I was going to help someone out, but they closed the thread before I could post. So I'll post my solution here for anyone who's having the same problem. 👍
Code
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Center Image</title>
        <style>
            * {
                box-sizing: border-box;
                padding: 0;
                margin: 0;
            }
            div.screen {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
            }
            figure {
                position: relative;
                top: 50%;
                left: 50%;
                display: block;
                width: 100%;
                max-width: 300px;
                height: 350px;
                background-color: skyblue;
                margin-left: -150px;
                margin-top: -175px;                
            }
            figcaption {
                font-family: Arial, Helvetica, sans-serif;
                font-size: 1.4rem;
                line-height: 1.5;
                color: #fff;
                text-align: center;
            }
        </style>
    </head>
    <body>
        <div class="screen">
            <figure>
                <img src="http://lorempixel.com/300/300" alt="placeholder image">
                <figcaption>Center Image</figcaption>
            </figure>
        </div>
    </body>
</html>
Life is a fig newton of you imagination! ~ https://www.brainwaveblitz.com/canyousol..._solve.php


Possibly Related Threads...
Thread / Author Replies Views Last Post
by craigOwnsYouNov 1, 2019 06:31 AM 2 128 Nov 1, 2019 06:31 AM
Last Post: AwesomeZephyr
[Wordpress] by Snowf0xOct 19, 2018 07:52 PM 3 148 Oct 19, 2018 07:52 PM
Last Post: cjbob
by iamnotactiveanymoreFeb 24, 2017 10:28 PM 3 175 Feb 24, 2017 10:28 PM
Last Post: ka$h