要使其正常工作,您可以使用类似将height:100%;width:100% 提供给正文和 html 的方法。
然后你创建一个容器 div 并给它height: 100 * <number of pages> %。
在每一页上,你给他们height: 100 / <number of pages> %。
由于这是基于百分比的,它可以在ANY分辨率下工作。
这里是完整的html+css:
<html>
<head>
<style type='text/css'>
html,body{height:100% !important;width:100% !important; margin:0px; padding:0px;}
.container {height: 500% !important; width: 100% !important;}
.page {height:20% !important; width:100% !important;}
</style>
</head>
<body>
<div class="container">
<div id="page1" class="page">
page1
</div>
<div id="page2" class="page">
page2
</div>
<div id="page3" class="page">
page3
</div>
<div id="page4" class="page">
page4
</div>
<div id="page5" class="page">
page5
</div>
</div>
</body>
</html>
您可以在此处查看实际情况:http://jsfiddle.net/tsgqnjfr/2/(5 页)和此处:http://jsfiddle.net/672fdmc4/2/(2 页)
如果你不能制作一个容器div,而不得不直接使用到body中,你可以这样制作:
你用height: 150%为2页和height: 50*<number of pages>+1 %设置body和html
然后将每个页面设置为height: 100/<number of pages>%。
喜欢这里:
<html>
<head>
<style type='text/css'>
html,body{height:250% !important;width:100% !important; margin:0px; padding:0px;}
.page {height:20% !important; width:100% !important;}
</style>
</head>
<body>
<div id="page1" class="page">
page1
</div>
<div id="page2" class="page">
page2
</div>
<div id="page3" class="page">
page3
</div>
<div id="page4" class="page">
page4
</div>
<div id="page5" class="page">
page5
</div>
</body>
</html>
您可以在此处查看:http://jsfiddle.net/tsgqnjfr/1/(5 页)和此处:http://jsfiddle.net/672fdmc4/1/(2 页)
注意:此方法不可靠,并给出“略微”错误的高度。
要尝试解决此问题,您可以尝试使用其他方法并为每个方法设置不同的高度,使用 body 作为容器 div。
更新
混合这两种方法,实际上WORKS可靠。
像这样:
<html>
<head>
<style type='text/css'>
html{height:100% !important;width:100% !important; margin:0px; padding:0px;}
body{height:500% !important;width:100% !important; margin:0px; padding:0px;}
.page {height:20% !important; width:100% !important;}
</style>
</head>
<body>
<div id="page1" class="page">
page1
</div>
<div id="page2" class="page">
page2
</div>
<div id="page3" class="page">
page3
</div>
<div id="page4" class="page">
page4
</div>
<div id="page5" class="page">
page5
</div>
</body>
</html>
查看它们的实际效果:http://jsfiddle.net/mgezx5f3/1/(5 页)和此处:http://jsfiddle.net/x2kz3od7/(2 页)。
注意:如果您担心兼容性,可以在支持 css 的EVERY BROWSER中使用这些方法,甚至在 IE 上的Quirks mode 中!
只要使用css,这个方法就可以工作(每个方法都有可靠性说明)。