这应该适用于IE7/8和其他非IE浏览器。
<p>
元素。这是由于空内容/填充/边框区域(在本例中为contentFrame)的展开边距造成的。参考
W3C Box Model
有几种方法可以解决这个问题,其中之一是引入一个薄(1px)边框,将其混合到DIV的背景中,然后用宽度/高度进行补偿。下面是另一个通过操纵
<P>
内容DIV中的元素。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body
{
-x-system-font: none;
background-color: #A2A2A2;
margin: 0;
margin-bottom: 35px;
padding: 0px;
}
#centeredframe
{
width: 1010px;
margin: 0 auto; /* merged */
padding: 0;
}
#contentframe
{
width: 1000px;
margin: 0;
padding: 5px;
background-color: #ffffff;
}
#content
{
padding: 0;
color: #ffffff;
background-color: #000000;
height: auto;
min-height: 300px;
}
#content p
{
margin: 0px; /* removed the default margin of p element*/
padding: 16px 0; /* replaced with padding to have background*/
}
</style>
</head>
<body>
<div id="centeredframe">
<div id="contentframe">
<div id="content">
<p>hgjghjghjghjg</p>
<p>hgjghjghjghjg</p>
<p>hgjghjghjghjg</p>
<p>hgjghjghjghjg</p>
</div>
</div>
</div>
</body>
</html>