简体   繁体   中英

Make a footer fill the remainder of the page with variable height content

Can someone point me in the right direction to make a footer fill the remainder of the page, when the body is variable height. All solutions I can find assume the header & body are of fixed height. Thanks in advance!

Get the height of the page content and the browser window via JS and set the height of the footer to heightofpage-heightofcontent.

let pagecontentheight = document.getElementById('pagecontent').offsetHeight;
let browserheight= window.innerHeight;

let footer= document.getElementById('footer');
footer.style.height = browserheight - pagecontentheight;

This will not work like that but It'll give you an idea of what I mean.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM