I have a website with several pages. each page has a different height (obviously, but I mention this).
what I would like to achieve is that if the content of the page is lower than the browser window, the footer tag will get a fixed position and will be aligned at the bottom of the page.
iv'e tried this js:
$(function(){ if ($(document).height() > $("footer").offset().top+44) { $("footer").addClass('fixbottom'); } } }); $(window).resize(function() { if ($(document).height() > $("footer").offset().top+44) { $("footer").addClass('fixbottom'); } });
and what css:
.fixbottom { width: 100%; position: fixed; bottom: 0; } footer { height:44px; background: #7abde9; color: #ffffff; text-align: center; }
the top + 44 in my jquery is that my bottom tag - 44 heights iv'e used a ready-made document and resized the window to make sure that all situations should occur, but, unfortunately, this does not work in any way.
any help should be greatly appreciated
source share