Stick the footer to bottom of your document

in code


Fuck fucking CSS. I wasted two hours wanking with combinations of CSS and JavaScript with the goal of pinning the footer to the bottom of the page. The one that worked was convoluted, requiring two divs and an arcane spread of rules. The jQuery code below works better, and it doesn’t require phantom divs.

function stickyFooter() {
    var footer = '#footer';

    if ($(footer).offset().top + $(footer).outerHeight() < $(window).height()) {
        $(footer).css({
            'bottom' : 0,
            'left' : 0,
            'right' : 0,
            'position' : 'fixed',
        });
    } else {
        $(footer).css('position', 'initial');
    }
}

If the footer's position from the top is less than the height of the window, add margin of the distance minus the footer's height to the top of the footer.



Remap a JavaScript Object

in code

Ik ben gelukkig

in me

Sacred Dissatisfaction

in running


Your email address will not be published. Required fields are marked *