Return to Snippet

Revision: 37579
at December 12, 2010 19:45 by Sullan


Initial Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>

		<title>A CSS Sticky Footer</title>

		<!--
		The second stylesheet is to make things look pretty.
		The first one is only the important one.
		-->

		<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<style type="text/css">

body {
	text-align: center;
}
.wrapper {
	position: relative;
	width: 700px;
	font-size: 0.9em;
	margin: 0 auto -142px;
	text-align: left;
}
.header {
	height: 190px;
	background: url(header.png) no-repeat;
}
h1 {
	text-indent: -500em;
}
h2 {
	padding: 0 0 0.6em;
	color: #d00;
	font: 1.4em helvetica,arial,sans-serif;
	text-shadow: #ddd 1px 1px 2px;
}
p {
	padding: 0 0 1em;
	color: #666;
	font: 1em/1.4em arial,sans-serif;
}
a {
	color: #000;
	text-decoration: none;
	border-bottom: 2px solid #0bf;
}
a:hover {
	color: #0bf;
}
strong {
	font-weight: normal;
}
.download {
	position: absolute;
	right: 0;
	top: 160px;
}
.footer {
	position: relative;
	width: 700px;
	margin: 0 auto;
	color:#333333;
	background: url(footer.jpg) no-repeat;
}
.footer a {
	text-decoration: underline;
	border: 0;
}
.footer p {
	position: absolute;
	left: 0;
	bottom: 4px;
	width: 700px;
	padding: 0;
	color: #fff;
	font: 0.8em arial,sans-serif;
	text-align: center;
}

* {
	margin: 0;
}
html, body {
	height: 100%;
}
.wrapper {
	min-height: 100%;
	height: auto !important;
	height: 100%;
	margin: 0 auto -142px; /* the bottom margin is the negative value of the footer's height */
}
.footer, .push {
	height: 142px; /* .push must be the same height as .footer */
}

/*

Sticky Footer by Ryan Fait
http://ryanfait.com/

*/
</style>

	</head>
	<body>

		<div class="wrapper">

			<div class="header">
				<h1>CSS Sticky Footer</h1>
			</div>

			<h2>A CSS sticky footer that just works</h2>
			<p>We've all tried to use a <strong>sticky footer</strong> one time or another, but they never seem to come out right, do they? Well, the days of a hard to understand CSS-based <strong>sticky footer</strong> are thankfully over. In just a few simple CSS classes with minimal extra HTML markup, I've fashioned a <strong>sticky footer</strong> that even beginners can get a handle on. It's been tested in IE 5 and up, Firefox, Safari and Opera.</p>
			<h2>Usage of the CSS</h2>

			<p><q>Great! this is exactly what I'm looking for! Can I use it?</q></p>
			<p>Absolutely. There are no terms, licenses, fees or requirements. Use it as you will. If you find the kindness to link to me on your site, I'd appreciate it, but it's by no means necessary. Have fun, and don't be afraid to ask me any questions or send me your thoughts.</p>
			<p class="download"><a href="layout.css" title="Download the stylesheet">View the CSS</a> or <a href="/resources/footer-stick-to-bottom-of-page/" title="Make a footer stick to the bottom of a page">learn about using it</a></p>

			<div class="push"></div>

		</div>

		<div class="footer">
			<p>Copyright &copy; 2006-2008 Ryan Fait &mdash; <a href="http://ryanfait.com/" title="Las Vegas Web Design">Las Vegas Web Design</a></p>
		</div>


		
	</body>
</html>

Initial URL


Initial Description


Initial Title
Footer fixed to the bottom

Initial Tags
css, html

Initial Language
HTML