css sticky footer


/ Published in: CSS
Save to your folder(s)

css sticky footer


Copy this code and paste it in your HTML
  1. /*
  2. Sticky Footer Solution
  3. by Steve Hatcher
  4.  
  5. http://stever.ca
  6.  
  7.  
  8. http://www.cssstickyfooter.com
  9.  
  10. */
  11.  
  12. * {margin:0;padding:0;}
  13.  
  14. /* must declare 0 margins on everything, also for main layout components use padding, not
  15. vertical margins (top and bottom) to add spacing, else those margins get added to total height
  16. and your footer gets pushed down a bit more, creating vertical scroll bars in the browser */
  17.  
  18. html, body {height: 100%;}
  19.  
  20. #wrap {min-height: 100%;}
  21.  
  22. #main {overflow:auto;
  23. padding-bottom: 150px;} /* must be same height as the footer */
  24.  
  25. #footer {position: relative;
  26. margin-top: -150px; /* negative value of footer height */
  27. height: 150px;
  28. clear:both;}
  29.  
  30. /*Opera Fix*/
  31. body:before {/* thanks to Maleika (Kohoutec)*/
  32. content:"";
  33. height:100%;
  34. float:left;
  35. width:0;
  36. margin-top:-32767px;/* thank you Erik J - negate effect of float*/
  37. }
  38.  
  39. /* IMPORTANT
  40.  
  41. You also need to include this conditional style in the of your HTML file to feed this style to IE 6 and lower and 8 and higher.
  42.  
  43. <!--[if !IE 7]>
  44.   <style type="text/css">
  45.   #wrap {display:table;height:100%}
  46.   </style>
  47. < ![endif]-->
  48.  
  49. */

URL: http://www.cssstickyfooter.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.