【发布时间】:2013-08-15 03:17:17
【问题描述】:
我正在尝试实现一个带有固定页眉和页脚的水平滚动网站。
目标: 1. 固定页眉和页脚 2.没有垂直滚动 3.内容div填充页眉和页脚之间的所有空间
我在内容上使用了 position: absolute 来确保 height:100% 占据页眉和页脚之间的区域。 (我的第三个目标) 但是,这也会导致出现垂直滚动条。
现场演示: http://jsfiddle.net/wQ2XR/230/
如何在不出现垂直滚动条的情况下实现我的目标?
提前非常感谢!
html代码:
<div id="total">
<header id="1">
<div id="a">
<h1>Header</h1>
</div>
</header>
<div id="2">
<div id="b">
<div id="bb">
<h2>Post Title Example One</h2>
<p>hello world! Have you thoroughly searched for an answer before asking your question? </p>
</div>
</div>
</div>
<footer id="3">
<div id="c">
<h1>footer</h1>
</div>
</footer>
</div>
CSS:
body, html {
height: 100%;
padding: 0;
margin: 0;
}
body {
width: 100%;
}
header {
}
#a {
position: fixed;
height: 50px;
top: 0;
width: 100%;
background-color: blue;
}
#2 {
position: relative;
padding: 50px 0 25px 0;
}
#b {
height: 100%;
position: absolute;
}
#bb {
position: relative;
height: 100%;
margin: 50px 0 0 0;
width: 2000px;
background-color: yellow;
}
footer {
}
#c {
position: fixed;
height: 25px;
bottom: 0;
width: 100%;
background-color: green;
}
【问题讨论】:
标签: html css css-position horizontal-scrolling