Skip to content

Instantly share code, notes, and snippets.

@cevarief
Created February 8, 2014 01:41
Show Gist options
  • Save cevarief/8875382 to your computer and use it in GitHub Desktop.
Save cevarief/8875382 to your computer and use it in GitHub Desktop.
Centering Div Vertically and Horizontally

Centering Div Vertically and Horizontally

html

<div class="container">
    <div class="content">
    I'm always<br/>
    In<br>
    Center :)
    </div>
</div>

css

html, body {
    width: 100%;
    height: 100%;
    display: table;
}

.container {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
}

.content {
    background-color: #dddddd;
    display: inline-block;
    text-align: center;
    padding: 5px;
    width:200px;
}
@SomeMinecraftModder
Copy link

can you rewrite in rust?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment