<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bloggerrific &#187; css footer</title>
	<atom:link href="http://www.davidjrush.com/blog/tag/css-footer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidjrush.com</link>
	<description>David J. Rush is a web designer and usability consultant in Pittsburgh who freelances and blogs about anything web related.</description>
	<lastBuildDate>Thu, 05 Jan 2012 02:50:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>CSS &#8211; Sticky Footer</title>
		<link>http://www.davidjrush.com/blog/2009/01/css-sticky-footer/</link>
		<comments>http://www.davidjrush.com/blog/2009/01/css-sticky-footer/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 15:15:00 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[CSS Tutorials and Tricks]]></category>
		<category><![CDATA[css footer]]></category>
		<category><![CDATA[css positioning]]></category>
		<category><![CDATA[css tricks]]></category>
		<category><![CDATA[sticky footer]]></category>
		<category><![CDATA[website layout]]></category>

		<guid isPermaLink="false">http://www.davidjrush.com/blog/?p=11</guid>
		<description><![CDATA[Almost all websites out there have what is called a footer, or a block at the bottom of the page with quick links. For example, my website has a footer at the bottom of the page if you scroll down with links to major sections of my site. When I was looking into implementing this [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: right; margin: 0px 0px 20px 20px; _margin: 0px 0px 10px 10px;" src="http://www.davidjrush.com/images/tutorials/stickyFooter.gif" alt="Sticky Footer Explanation" width="351" height="251" />Almost all websites out there have what is called a footer, or a block at the bottom of the page with quick links. For example, my website has a footer at the bottom of the page if you scroll down with links to major sections of my site. When I was looking into implementing this on my site, I ran into some problems. On some pages, the content didn&#8217;t fill the whole screen (which also varies with different screen resolutions, so the footer would be in the middle of the screen. Obviously, on pages where the content went past the bottom of the screen, this wouldn&#8217;t be a problem because the footer would be pushed to the bottom. So clearly, I needed a footer that would &#8220;stick&#8221; to the bottom of the screen if the content wouldn&#8217;t push it, but if there was enough content, then it would be below the screen bottom. I searched and searched for solutions, and I found one which I adapted just a little bit into my own implementation (in thanks, here is a link to his site, <a href="http://ryanfait.com/sticky-footer/" target="_blank">ryanfait.com</a>.</p>
<p>Ryan&#8217;s solution was fantastic. However, I did still have some problems with it, probably because of my wrapper div that I used to center my content. So below, I have implemented my fix which I have tested in Firefox 2 and 3, Internet Explorer 6 and 7, Safari, Opera, and Chrome. The footer sticks to the bottom of the screen when content doesn&#8217;t push it that far, but goes to the bottom of the page when content goes below the fold. Below is the CSS and HTML for the footer with a wrapper as well. The sticky footer combined with a wrapper allow you to account for pretty much any <a href="http://www.davidjrush.com/blog/2008/12/screen-resolution-size-matters/"> screen resolution</a>) too, which is fantastic! However, there is just one downside to this sticky footer, you absolutely MUST know the height of your footer. Luckily, there are not many cases where you&#8217;d be putting dynamic content into your footer.</p>
<p><span style="font-weight:bold;">First, the CSS:</span></p>
<pre class="brush: css; title: ; notranslate">html{
   height: 100%;
}
body{
   height: 100%;
}
div.wrapper {
   min-height: 100%;
   height: auto !important;
   height: 100%;
   margin: 0 auto -100px auto;
   /*The -100px mentioned above needs to be the exact height of the footer.*/
}
div.footer{
   height: 100px;
   clear: both;
   position: relative;
}
div.nudge{
   height: 100px;
   clear: both;
}</pre>
<p><span style="font-weight:bold;">And now the HTML:</span></p>
<pre class="brush: xml; title: ; notranslate">&lt;html&gt;
  &lt;body&gt;
    &lt;div class=&quot;wrapper&quot;&gt;
      Your main content goes in here
      &lt;div class=&quot;nudge&quot;&gt;&lt;/div&gt;
      &lt;!--The nudge div should remain empty and makes space for the negative margin assigned above.--&gt;
    &lt;/div&gt;
    &lt;div class=&quot;footer&quot;&gt;
      Your footer content goes in here
    &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p>To see a working example of this footer, obviously you can look on this page (because I have one implemented here), or you can check out this <a href="http://www.davidjrush.com/tutorials/css-sticky-footer-example/" target="_blank">example page</a> that I made.</p>
<p>So yeah, it works pretty simply, though I must stress that every line of that CSS is important. You must declare a 100% height for the two parent elements of html and body (and if you have any other tags between those and the wrapper div, then you need a 100% on that as well). This forces the browser to use the whole screen. The three separate height declarations for the wrapper div are each individually important, including the !important addition. &quot;!important&quot; is a statement which makes that lines declaration take precedence over declarations that come after it. This however does not apply in IE, but that&#8217;s okay, because we want it that way for this Sticky Footer. Then most important is how the margins work. By putting a negative margin of the footer&#8217;s height on the wrapper, we allow whatever comes after the wrapper to overlap with it. The nudge div creates empty space inside the main wrapper so that when the footer overlaps exactly with the wrapper, nothing is blocked out. If you theoretically wanted a margin between the wrapper and the footer then make your negative margin on the wrapper 100px, your footer div would be 70, and give the footer a 30px margin on top. The nudge div would also still be 100px again to make space for the footer and its margin.</p>
<p>As a last suggestion, I usually put another div inside the wrapper div and the footer div, give them both a width of 990px and make them float left. The float with the full width will make sure that nothing (such as padding or a margin) manages to creep outside the edge of the wrapper or footer div. This is a safety precaution, but one that I highly suggest. If you notice a problem when you try to implement the sticky footer, this is the first thing that I would suggest.</p>
<p>UPDATE: A common problem that I&#8217;ve seen people run into when implementing this sticky footer is having trouble making your wrapper div take up a defined amount of space in the browser&#8217;s eyes. Floating (as discussed above), or the <a href="http://www.w3schools.com/css/css_display_visibility.asp" target="_blank">CSS display property</a> help the browser know how big a div physically is. If the browser can&#8217;t figure that out, then the footer won&#8217;t align to the bottom correctly. Either add a float to a div immediately inside the wrapper, or add &quot;display: inline-block;&quot; as a style definition to the wrapper div.</p>
<p>Got any questions? Need help troubleshooting? Critiques are welcomed too! Post a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidjrush.com/blog/2009/01/css-sticky-footer/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>

