html - 如何将页脚保持在页面底部?

标签 html css

<分区>

CSS

 * {
     margin: 0px;
     padding: 0px;
 }
 html {
     margin: 0px;
     padding: 0px;
 }
 body {
     line-height: 1;
     margin: 0px;
     padding:0px;
     background:url("../images/22.jpg") scroll center top #16202C;
     /*  box-shadow: 0 0 225px rgba(0, 0, 0, 0.45) inset;
    -webkit-box-shadow: 0 0 225px rgba(0, 0, 0, 0.45) inset;
    -moz-box-shadow:  0 0 225px rgba(0, 0, 0, 0.45) inset;
-o-box-shadow:  0 0 225px rgba(0, 0, 0, 0.45) inset; */
     color: #464646;
     font: 13px/17px arial, sans-serif;
     min-width: 1300px;
 }
 #wrapper {
     margin: 0px;
 }
 #header {
     height: 40px;
     width: 100%;
 }
 #bodyWrapper {
     width: 980px;
     margin: 0px auto;
     position: relative;
     z-index: 2;
     -webkit-box-shadow: 0px 0px 2px #000 outset;
     -moz-box-shadow: 2px 0px 2px #000 outset;
     box-shadow: 20px 0px 2px #000 outset;
 }
 #bodyDiv {
     min-height: 550px;
     height: 100%;
     background:#fff;
     padding:20px 10px;
 }
 #footer {
     background: url("../images/footer_back.png") repeat-x scroll left top transparent;
     height: 100px;
     margin-top: -50px;
     position: relative;
     width: 100%;
     z-index: 1;
 }

HTML

<body>
    <div id="topHeaderBar"></div>
    <div id="wrapper">
        <div id="bodyWrapper">
            <div id="header">
                <jsp:include page="menu.jsp"></jsp:include>
            </div>
            <div id="bodyDiv" style="position: relative;">body content</div>
            <div id="footer">
                <jsp:include page="footer.jsp"></jsp:include>
            </div>
        </div>
</body>

请帮帮我,我无法调整页面底部的页脚
当正文内容较少时,页脚将向上移动,#bodyDiv 中的 min-height:550px 在不同的屏幕分辨率下会产生问题

最佳答案

试试这个:

 #footer {
     background: url("../images/footer_back.png") repeat-x scroll left top transparent;
     height: 100px;
     margin-top: -50px;
     position: fixed;
     bottom:0;
     width: 100%;
     z-index: 1;
 }

关于html - 如何将页脚保持在页面底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17783937/

相关文章:

html - 获取 Google Chart 图片以填充 DIV 的宽度

javascript - 在 Tumblr 中嵌入 HTML5 视频(仪表板和博客)

css - 标题中的 Logo 加载,然后在移动 View 中消失

html - nth-child(even) 不工作,但奇怪的工作

html - 垂直居中 <a> 标签?

PHP While循环将空白行添加到重复区域

javascript - 网格元素垂直初始化 Gridster.js

html - 阻止悬停在内部元素上?

css - 如何在CSS中制作一个 flex 的边缘容器

html - 列在 IE 中自行折叠