Skip to content

Instantly share code, notes, and snippets.

@amadrzyk
Last active June 21, 2017 22:17
Show Gist options
  • Select an option

  • Save amadrzyk/fc21013002e180f08cb128c5c98f360f to your computer and use it in GitHub Desktop.

Select an option

Save amadrzyk/fc21013002e180f08cb128c5c98f360f to your computer and use it in GitHub Desktop.
How to Vertically Align a Div
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Vertical Align</title>
<style>
html, body {
width: 100%;
height: 100%;
overflow: hidden;
}
.container {
width: 100%;
height: 100%;
}
.center-row {
width: 100%;
height: 100%;
display: table;
margin: 0;
}
.center-col {
width: 100%;
text-align: center;
display: table-cell;
vertical-align: middle;
float: none;
}
</style>
</head>
<body>
<div class="container">
<div class="row center-row">
<div class="col-xs-4 center-col">
<p> hello </p>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment