首页 > 如何让一个div永远出现在界面的最底部

如何让一个div永远出现在界面的最底部

用js获取屏幕的宽度,然后定位
其他其他更好的办法


这个问题有点类似How to use the CSS Sticky Footer on your website,不知道@binphp 是不是这个意思。我一直在用这个方法,跨浏览器的,可以保证footer一直在底部,不管屏幕多长。

CSS文件:

* {
margin: 0;
}

html, body {
height: 100%;
}

.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -4em;
}

.footer, .push {
height: 4em;
}

HTML文件:

<html>
    <head>
        <link rel="stylesheet" href="layout.css" ... />
    </head>
    <body>
        <div class="wrapper">
            <p>Your website content here.</p>
            <div class="push"></div>
        </div>
        <div class="footer">
            <p>Copyright (c) 2008</p>
        </div>
    </body>
</html>

原文 -> http://ryanfait.com/resources/footer-...
Demo -> http://ryanfait.com/sticky-footer/


.test {
    position:fixed;
    bottom:0;
    left:0;
}

ie6支持position:fixed;不能,会相当于position:absolute;,好像可以用expression吧

【热门文章】
【热门文章】