Created
August 11, 2012 18:34
-
-
Save maxparm/3326245 to your computer and use it in GitHub Desktop.
Center vertically any content in CSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<style type="text/css"> | |
.wrapper { | |
height:200px; | |
border:2px solid #CCC; | |
background:#eee; | |
} | |
.vertically-centered { | |
display:table; | |
height:100%; | |
width:100%; | |
} | |
.vertically-centered div { | |
display:table-cell; | |
height:100%; | |
width:100%; | |
vertical-align:middle; | |
text-align:center; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="wrapper"> | |
<div class="vertically-centered"> | |
<div><span>centered content<span></div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment