CSS keeping the footer at the bottom

Spent enough time trying different methods across the web but only 1 article worked for me using the "push" div layer. Loosely based on Ryanfait: Make a Footer Stick to the Bottom of the Page




<div id="container">
     <div id="header"></div>
     <div id="content">
          <div id="left"></div>
          <div id="right"></div>
          <div class="push"></div>
     <div id="footer"></div>
  1.  <div id="container"> 
  2.       <div id="header"></div> 
  3.       <div id="content"> 
  4.            <div id="left"></div> 
  5.            <div id="right"></div> 
  6.            <div class="push"></div> 
  7.       </div> 
  8.       <div id="footer"></div> 
  9.  </div> 
The header displayed fine. The left and right columns finally got them side by side. But the footer that has a background image was under the left and right columns... The main content layer was overlapping the footer. I tried various z-index's bearing in mind that the footer has to be behind because the main content had a semi-transparent layer that overlapped it half-way.

I managed to fix this by including a div push layer which clears both (even though i had clear:both on the css for my #right div layer). For some reason, it has a more forceful effect in its own separate layer.

In a joomla CMS template though, I wanted the "left" div to take over the whole page if there were no modules positioned in the "right" div. I specified width of left using PHP. This is the CSS though:
#container {
	position: relative;
#content {
	position: relative;
	top: 0;
	width: 900px; 
	margin: 0 auto;
	min-height: 500px; /* to stop footer coming up on empty pages */
	background-image: url("../images/bg_contentbox.png"); /* semi transparent background */
#footer {
	position: relative;
	height: 250px; /* height of my footer */
	background-color: #8cc553;
	z-index: -1;
#left {
	float: left;
	margin: 0;
	padding: 0;
.push {
#right {
	margin: 0 0 0 20px;
	padding: 0;
  1.  #container { 
  2.      position: relative; 
  3.  } 
  4.  #content { 
  5.      position: relative; 
  6.      top: 0
  7.      width: 900px
  8.      margin: 0 auto; 
  9.      min-height: 500px; /* to stop footer coming up on empty pages */ 
  10.      background-image: url("../images/bg_contentbox.png"); /* semi transparent background */ 
  11.  } 
  12.  #footer { 
  13.      position: relative; 
  14.      bottom:0
  15.      margin:0
  16.      padding:0
  17.      width:100%; 
  18.      height: 250px; /* height of my footer */ 
  19.      background-color: #8cc553; 
  20.      z-index: -1
  21.  } 
  22.  #left { 
  23.      float: left; 
  24.          width:500px
  25.      margin: 0
  26.      padding: 0
  27.  } 
  28.  .push { 
  29.      clear:both; 
  30.  } 
  31.  #right { 
  32.      float:left; 
  33.      width:380px
  34.      margin: 0 0 0 20px
  35.      padding: 0
  36.  } 
Category: Cascading Stylesheets :: Article: 350

Credit where Credit is Due:

Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman

Related Articles

Joes Revolver Map


Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Donate to Joel Lipman via PayPal

Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 bc1qjtp4l4ra452wzvuk9a45yfj82zkahsyy2z379y
© 2023 Joel Lipman .com. All Rights Reserved.