【发布时间】:2011-06-15 05:49:05
【问题描述】:
以下代码中的<h3> 强制垂直滚动条,这反过来又导致页面顶部出现空白(红色;即body)。
为什么?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<title>Test</title>
<style type="text/css">
html { height: 100%; }
body {
background-color:#f00;
margin:0;
padding:0;
height:100%;
}
#divParent1 {
background-color:#0f0;
background-image:url("example1_bg.png");
background-repeat: repeat;
height:100%;
margin:0 auto;
padding:0;
}
#div1 {
background-image:url(example1_white_center.png);
background-repeat: repeat-y;
background-position: center;
width:1200px;
min-width:1200px;
_width:1200px;
height:100%;
margin:0 auto;
}
#div2{
background-image:url(example1_dgreen_blank.png);
background-repeat: no-repeat;
height:100%;
margin:0;
}
</style>
</head>
<body>
<div id="divParent1">
<div id="div1">
<div id="div2">
<div style="width:100%; position:relative; top:240px; margin:0;">
<div style="margin:0 auto; width:570px; background-color:#00f; ">
<h3>LOLOL</h3>
hi<br>hi<br>hi<br>hi<br>hi<br>hi<br>hi<br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
注意:这个结果不能在 jsfiddle 上复制,让我更加困惑。
【问题讨论】: