Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wellyington/46bdd262e732c370a1da6ba8c0c75fcd to your computer and use it in GitHub Desktop.
Save wellyington/46bdd262e732c370a1da6ba8c0c75fcd to your computer and use it in GitHub Desktop.
Vertical & Horizontal Centered HTML/CSS Layout
<html>
<head>
<style>
.container {
height:100vh;
position:relative;
margin:0;
padding0;
}
.center {
margin:0;
position:absolute;
top:50%;
left:50%;
-ms-transform:translate(-50%, -50%);
transform:translate(-50%, -50%);
}
</style>
</head>
<body>
<div class="container">
<div class="center">
<span>I am the centre of the WORLD! :)</span>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment