Div at bottom of window and adaptable height div

流过昼夜 提交于 2019-11-30 15:39:48

you can take a look at "Exploring Footers" at A List Apart,

http://www.alistapart.com/articles/footers/

hope it helps, Sinan

EDIT: (pure CSS way)

Your Markup:

<div class="non-footer">Your content goes here.</div>
<div class="footer">Here is for footer content.</div>

Your CSS:

body, html, .non-footer {
    height: 100%;
    min-height: 100%;
    width: 100%;
}
.footer {
    height: 150px;
    margin-top: -150px;
    width: 100%;
}

I might be missing some details, but this should work and it gives the basic idea behind the trick.

Sinan.

you should use fixed instead of absolute

position: fixed;
bottom: 0;
deV

Test this. Put this in the head:

<script>
    var int=self.setInterval(function(){clock()},100);

    function clock()
    {
        var s = document.getElementById("Footer");
        s.style.position = "Fixed";
        s.style.bottom = "0px";
        s.style.margin = "0px";
        s.style.height = "20px";
        s.style.width = "30px";
    }

    window.onload=clock
</script>

The html:

<div id="Footer"></div>

try this: set the orange div position relative with a bottom margin = height of the green div with an overflow: auto

I think your orange div will then scroll if it becomes larger then the space between the white and green div. to solve your background problem, you can easily set orange as background color. In that way, it will never be visible for a user that your orange div is in fact smaller as the space between the white and green divs

I don't think this is possible without working out the size of the centre div using Javascript.

CSS positioning basically flows from the top down, so to get a div to stick at the bottom of the page you need to take it out of the flow of the page using position:absolute (or position:fixed)

But now that div is out of the flow of the page, so the middle div doesn't know to stop at the top of the bottom div. It will just carry on behind the bottom div and won't display scrollbars.

Massimiliano Rossi

You can use the following solution to get the orange div to do what you want:

if ( ( $('.container-with-footer').height() ) < ( $(window).height() ) ) {
    $('footer').css({
        "position":"absolute",
        "left":"0",
        "right":"0",
        "bottom":"0"
    })
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!