我写了这个粘性页脚模板,我希望我的内容div具有100%最小高度。问题是,当我这样做时,它会在页脚下面延伸,并具有页眉高度+页脚高度的额外高度。我怎样才能解决这个问题?它应该同样支持短内容和长内容,与粘滞页脚相同。我需要使用jQuery吗?我是初学者,所以请KISS。粘性页脚问题 - 我如何得到内容高度100%减号页眉和页脚
HTML
<body>
<form id="form1" runat="server">
<div class="wrapper">
<div class="header"></div>
<div class="content">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="footer"></div>
</div>
</form>
</body>
CSS
html, body {
min-height:100%;
height:100%;
}
#form1 {
min-height:100%;
height:100%;
margin:0;
}
.wrapper {
min-height:100%;
height:100%;
position:relative;
}
.header {
background:#990066;
height:100px;
}
.content {
background:#ffffcc;
padding-bottom:100px; /* Height of the footer */
min-height: 100%;
width: 1120px;
margin: 0 auto;
}
.footer {
position:absolute;
bottom:0;
width:100%;
height:100px; /* Height of the footer */
background:#333;
}
我不想一个固定的页脚。当内容很少时,它必须坚持到底。当内容很长时,我希望页脚在内容结尾处自然下滑。 页脚不是我的问题。我想要的内容div相同: 当内容很少时,我希望内容div伸展到页脚。当内容很多时,我希望内容div自然伸展以包含所有内容。 – 2013-03-28 11:32:24
我认为它不可能不使用js所以你应该添加一些js根据页面的高度在内容div中添加高度。 – Nilesh 2013-03-28 12:01:03