<div>
<div id="div">
<div id="div1">LEFT</div>
<div id="div2">RIGHT</div>
</div>
</div>
#div
{
width:500px;
height:40px;
}
#div1
{
width:250px;
height:40px;
float:left;
}
#div2
{
width:250px;
height:40px;
float:left;
}在IE8中DIV1和DIV2可以同行显示,但在IE7不能,什么原因
这样
加上
div{padding:0;border:0;margin:0}
{
width:510px;
height:40px;
}
没有把 display:inline 是不会同行显示的 除非 用了float
找找css文件中有没有样式是直接给div元素定义的
<html>
<body>
<div style=" width:300px;border: 1px solid #cdcdcd;">
<div style="border: 1px solid #A5B6C8; width:80;float: left;">111</div>
<div style="border: 1px solid #A5B6C8; width:80;float: left;">111</div>
<div style="border: 1px solid #A5B6C8; width:80;float: left;">111</div>
<div style="border: 1px solid #A5B6C8; width:80;float: left;">111</div>
<div style="border: 1px solid #A5B6C8; width:80;float: left;">111</div>
<div style="border: 1px solid #A5B6C8; width:80;float: left;">111</div>
<div style="border: 1px solid #A5B6C8; width:80;float: left;">111</div>
<div style="border: 1px solid #A5B6C8; width:80;float: left;">111</div>
</div>
</body>
</html>
把高度去掉试试,高度这个可以通过设置padding,防止div中的文字太靠近边框。
用firebug看看,是不是继承了其他样式。