HTML Coolness: a true 100% height layout
Great code from MB!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
margin:0;
padding:0;
height:100%;
}
.container {
width:800px;
min-height:100%;
margin:auto;
background-color:#CCCCCC;
position:relative;
}
.footer {
position:absolute;
bottom:0px;
width:100%;
height:100px;
background-color:#666666;
}
/* Since the footer is absolutely positioned, resizing the page would cause the footer to cover up any other content you have. The following clearfooter div sits behind the footer and prevents the content from being hidden. The height can be adjusted to provide more or less padding between the bottom of your content and the top of the footer. */
.clearfooter {
height:110px;
}
/* And finally, a little CSS hack to get this to work on IE6 */
* html .container {height:100%;}
</style>
</head>
<body>
<div class="container">
<!--I've purposely left out the <p> tag here as it was causing some unwanted padding/margin problems in Firefox and Safari. You can always specify these properties in the styles above, but I left them out to keep the focus on the CSS for the layout. -->
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
<div class="clearfooter"></div>
<div class="footer">Footer contents here</div>
</div>
</body>
</html>
0 Comments:
Posta un commento
<< Home