Posted By


jayphen on 03/07/10

Tagged


Statistics


Viewed 624 times
Favorited by 3 user(s)

jQuery Sticky Footer


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



Copy this code and paste it in your HTML
  1. //footer stick
  2. $(window).bind("load", function() {
  3.  
  4. var footerHeight = 0,
  5. footerTop = 0,
  6. $footer = $("#footer");
  7.  
  8. positionFooter();
  9.  
  10. function positionFooter() {
  11. footerHeight = $footer.outerHeight();
  12. footerTop = ($(window).scrollTop()+$(window).height()-footerHeight)+"px";
  13. if ( ($(document.body).height()+footerHeight) < $(window).height()) {
  14. $footer.css({
  15. position: "absolute",
  16. top: footerTop
  17. });
  18. } else {
  19. $footer.css({
  20. position: "static"
  21. });
  22. }
  23. };
  24. $(window)
  25. .scroll(positionFooter)
  26. .resize(positionFooter);
  27.  
  28. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.