Created
January 27, 2011 15:39
-
-
Save moudy/798650 to your computer and use it in GitHub Desktop.
aligns a div vertically on a page
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> | |
<style type="text/css"> | |
html,body{ | |
height:100%; | |
margin:0; | |
padding:0;} | |
#offset{ | |
width:100%; | |
height:50%; | |
margin-top:-250px; /* half of content height*/ | |
float:left;} | |
#page { | |
width:700px; | |
height:500px; | |
margin:0 auto; | |
border:1px solid #444; | |
overflow:auto; /* allow scrolling in element */ | |
clear:both;} | |
</style> | |
</head> | |
<body> | |
<div id="offset"></div> <!--invisible, causes following div to be vertically centered--> | |
<div id="page"> | |
<!--content here--> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment