I'm looking to display a footer with the user's name on my sidebar at the bottom of the viewport. I want it to act as a fixed bottom bar, always visible but only within the sidebar.
To achieve this, I have created a function:
function setFooterStyle() {
var docHeight = $(window).height();
var footerHeight = $('#footer').outerHeight();
var footerTop = $('#footer').position().top + footerHeight;
$('#footer').css('margin-top', (docHeight - footerTop) + 'px');
$('#footer').removeClass('invisible');
}
This function is then implemented like so:
$( function () {
setFooterStyle();
window.onresize = setFooterStyle;
}
However, because I am using a sidebar, I suspect that the margin-top positioning places the footer below the sidebar rather than at the top of the page. As a result, the footer ends up hidden towards the bottom of the document and requires scrolling to view it.
Can anyone provide insight into what might be causing this issue and how I can ensure that the footer remains at the bottom of the viewport regardless of resizing or scrolling?