您可以将以下方法与纯 CSS 和无表格一起使用。
在此处查看在线演示。
结果:
然而,这意味着您需要稍微更改文档结构(我使用的是 HTML5 元素,但如果需要,这可以很容易地更改为普通的 div) - 正如您所看到的结构相当简单:
<header>Header
<nav>Menu</nav>
</header>
<main>
<div class="page">
<h3>Page 1</h3>
scroll from main scrollbar
....
</div>
<div class="page">
<h3>Page 2</h3>
scroll from main scrollbar
....
</div>
</main>
<footer>Footer</footer>
现在它只是一个样式问题,以便您可以使用主滚动条滚动“两个”页面。在这种情况下的基本类是:
.page {
float:left;
margin:70px 10px 50px 10px;
border:1px solid #000;
width:45%;
}
该类的重要部分page
是其顶部和底部边距设置为匹配页眉和页脚。即使页眉和页脚已固定,这也是使两个页面可见的原因。
其余的 CSS 只是举例:
html, body {
width:100%;
height:100%;
margin:0;
padding:0;
}
header {
position:fixed;
top:0;
width:100%;
height:70px;
font:32px sans-serif;
color:#fff;
background:#555;
}
nav {
position:absolute;
bottom:0;
font:12px sans-serif;
}
footer {
position:fixed;
width:100%;
bottom:0;
height:50px;
background:#555;
}