<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>StickyFooter</title>
<style type="text/css" media="screen">
/* must declare 0 margins on everything, also for main layout components use padding, not
vertical margins (top and bottom) to add spacing, else those margins get added to total height
and your footer gets pushed down a bit more, creating vertical scroll bars in the browser */
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
#container {
min-height: 100%;
}
#main {
overflow: auto;
padding-bottom: 150px; /* must be same height as the footer */
}
#footer {
position: relative;
margin-top: -150px; /* negative value of footer height */
height: 150px;
clear: both;
}
/*Opera Fix*/
body:before {
content: "";
height: 100%;
float: left;
width: 0;
margin-top: -32767px;
}
</style>
</head>
<body>
<div id="container">
<div id="header">
<h1>Header 1</h1>
</div>
<div id="main">
<p>Content here.</p>
</div>
</div>
<div id="footer">
<p>Footer.</p>
</div>
</body>
</html>
HTML: Sticky Footer
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.