Skip to content

Instantly share code, notes, and snippets.

@vimm0
Created August 21, 2024 13:17
Show Gist options
  • Save vimm0/01b6935c603e78b4c702f4107857ec98 to your computer and use it in GitHub Desktop.
Save vimm0/01b6935c603e78b4c702f4107857ec98 to your computer and use it in GitHub Desktop.

Revisions

  1. vimm0 created this gist Aug 21, 2024.
    38 changes: 38 additions & 0 deletions center-div.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    <!DOCTYPE html>
    <html>

    <head>
    <style>
    body {
    background-color: blue; /* optional */
    }

    .container {
    background-color: black; /* optional */
    height: 50vh; /* optional */
    display: flex;
    justify-content: center;
    align-items: center;
    }

    .box {
    height: 150px; /* optional */
    width: 150px; /* optional */
    color: white; /* optional */
    background-color: red; /* optional */
    display: flex;
    justify-content: center;
    align-items: center;
    }
    </style>
    </head>

    <body>
    <div class="container">
    <div class="box">Centered!
    </div>
    </div>

    </body>

    </html>