首页 新闻 赞助 找找看

DIV!!求急??

0
[已解决问题] 解决于 2008-06-09 09:04
<P>源代码:&nbsp;</P> <P><FONT color=#000000>&lt;html&gt;<BR>&lt;div style="float:left;margin-left:10px;background:red;width:20px;height:20px;"&gt;&lt;/div&gt;<BR>&lt;div style="float:left;background:green;width:20px;height:20px;"&gt;&lt;/div&gt;<BR>&lt;div style="float:left;background:blue;width:20px;height:20px;"&gt;&lt;/div&gt;<BR>&lt;div style="clear:left;margin-left:10px;background:black;width:20px;height:20px;"&gt;&lt;/div&gt;<BR>&lt;/html&gt;</FONT></P> <P>在IE7和FF里显示如下:</P> <P><IMG height=73 src="http://www.cnblogs.com/images/cnblogs_com/chjw8016/102272/o_2008-06-08_191453.png" width=91 mce_src="http://www.cnblogs.com/images/cnblogs_com/chjw8016/102272/o_2008-06-08_191453.png"></P> <P>在IE6时里显示如下:</P> <P><IMG height=79 src="http://www.cnblogs.com/images/cnblogs_com/chjw8016/102272/o_2008-06-08_191435.png" width=100 mce_src="http://www.cnblogs.com/images/cnblogs_com/chjw8016/102272/o_2008-06-08_191435.png"></P> <P>为什么在IE6里面,上面的第一个DIV的Margin-left会多出10px呢?</P>
伽马科技.攻城师的主页 伽马科技.攻城师 | 小虾三级 | 园豆:1303
提问于:2008-06-08 19:23
< >
分享
最佳答案
0
这是ie6中一个十分经典的Bug,即:靠边浮动的元素的margin加倍。这时只要将此元素(背景色为红色的元素)的display属性改为inline。 修改后的代码: <html> <div style="float:left;margin-left:10px;background:red;width:20px;height:20px;display:inline;"></div> <div style="float:left;background:green;width:20px;height:20px;"></div> <div style="float:left;background:blue;width:20px;height:20px;"></div> <div style="clear:left;margin-left:10px;background:black;width:20px;height:20px;"></div> </html>
Rain Man | 初学一级 |园豆:131 | 2008-06-08 23:19
其他回答(2)
0
在web 中遇见,网页溢出或者,收缩的现象,最好的办法就是用,百分比控制,同意楼上...您可以试试...
Jared.Nie | 园豆:1940 (小虾三级) | 2008-06-08 20:23
0
当设置向左或向右浮动时,对应的为左边或右边设的margin在IE6下有bug,需要用Css Hack解决。单独设置IE6的margin,以保证多个浏览器下页面保持一致。这个属于IE6的解析问题。 在IE的新版本IE7或IE8中已解决此bug
任力 | 园豆:1124 (小虾三级) | 2008-06-08 21:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册