在ASP.NET页面中实现CSS粘性页脚

3
我将尝试创建一个固定在页面底部的页脚。我已经做了以下工作:
<body>
    <form id="form1" runat="server">
    <div id="wrap">
        <div id="content">
            <uc2:logo ID="logo1" runat="server" />
        </div>
    </div>
    <uc1:footer ID="footer1" runat="server" />
    </form>
</body>

这是我的CSS样式:
body {
    margin: 30px 10px 0px 10px;
    font-size: 14px;
    font: 76% Arial,Verdana,Helvetica,sans-serif;
}
html, body, form, #wrap { height: 100%; }
form > #wrap { height: auto; min-height: 100%; }

#wrap {
    width: 1000px;
    margin: auto;

}

#content {

    text-align:left;

}


#footer {
 clear: both;
 position: relative;
 z-index: 10;
 width:1000px;
 margin:auto;
}

我缺少什么?页脚出现在视口下方(页面上也有滚动条)。我认为这可能是某种边距问题。

2个回答

6

4
必须在关于 body 和 html 元素的 CSS 规则中添加表单元素,然后它才能正常工作。 - FiveTools

1

尝试使用绝对定位:

#footer {
 clear: both;
 position: absolute;
 z-index: 10;
 width:1000px;
 margin:auto;
 bottom:0px;
 height:50px;
}

是的 - 位置: 绝对; 也在解决方案中。谢谢! - FiveTools

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接