How to stick footer to bottom? With a little twist

此生再无相见时 提交于 2019-12-12 10:16:39

问题


So basicly i want to stick footer on the bottom of my page

But the content of my page is dynamic, so in some cases the content is long, in some cases it is short

I've searched through google and found many results, but when i try it, they work when the content is short, but if the content is long it will stick on the bottom of the window (not page) and overlap the content

It's not matter if it uses javascript, but if you have the pure CSS ones it will be better


回答1:


This doesn't use a fixed position so it won't always show up at the bottom of your viewport.

CSS from here

You can also see a discussion about this here

* {
    margin: 0;
}
html, body {
    height: 100%;
}
.wrapper {
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin: 0 auto -142px; /* the bottom margin is the negative value of the footer's height */
}
.footer, .push {
    height: 142px; /* .push must be the same height as .footer */
}

/*

Sticky Footer by Ryan Fait
http://ryanfait.com/

*/



回答2:


#footer{
    position:fixed; 
    bottom:0;
    height:200px;
}

body
{
    min-height:100%;
    padding-bottom:200px; /* same as footer height */
}



回答3:


I could find a css solution ( Not 100% )

#footer {
   position:fixed;
   left:0px;
   bottom:0px;
   height:30px;
   width:100%;
   background:#999;
}

/* IE 6 */
* html #footer {
   position:absolute;
   top:expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');
}

at this link below Fixed css footer

You can take also look into other SO postings

Footer position bottom and center

how to make footer fixed in a page



来源:https://stackoverflow.com/questions/14179481/how-to-stick-footer-to-bottom-with-a-little-twist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!