开发者

Positioning at bottom of webpage

开发者 https://www.devze.com 2023-03-16 04:30 出处:网络
I have a weird CSS problem. I have a banner that I need to position at the bottom of every page. To this end I have set body to position: relative; and my banner to position absolute; bottom: 0px;

I have a weird CSS problem. I have a banner that I need to position at the bottom of every page.

To this end I have set body to position: relative; and my banner to position absolute; bottom: 0px;

The problem is my banner positions differently on different pages such as the following: 开发者_如何学JAVAhttp://www.plotsandhouses.com/node/1, http://www.plotsandhouses.com/node/29, http://www.plotsandhouses.com/node/30

The 'custom-page_closure_wrapper' div is what I am trying to position at the bottom of the pages. I can do this by setting position: fixed; but I don't really want the div visible at all times - only when the bottom of the page is visible or the user scrolls down to see it.

What am I missing?


To add on to Marc's answer, there is a CSS solution to it called the Sticky Footer.

The reason why your footer doesn't "stick" to the bottom of the page is because the height of the container where the footer is absolutely positioned in is not more than the height of the viewport. Therefore, by forcibly stretching the container to the full height, the technique ensures that the footer always stays at the bottom.


You can try adding the following in your CSS file:

body {height:100%;}
#custom-body-wrapper {height:100%;} /*this is the container of your absolute div*/

and removing the position:relative on your body tag.

0

精彩评论

暂无评论...
验证码 换一张
取 消