如何解决IE6的双倍margin、IE6不支持png透明的bug问题IE6的双倍margin你是否很烦恼IE6双倍margin间距?这里和大家简单分享一下,IE6双倍margin间距解决方法方法1:
如何解决IE6的双倍margin、IE6不支持png透明的bug问题
IE6的双倍margin
你是否很烦恼IE6双倍margin间距?这里和大家简单分享一下,IE6双倍margin间距解决方法
方法1:
假设:一个div代码为
<div style="float:left;margin-left:10px;"></div>
当一个css样式同时设置了float和margin的属性的时候,在ie7+及火狐上,该元素显示正常。但是在ie6下,将会出现双倍的margin-left属性值,也就是上面那段代码中的div在ie6下的实际margin-left的值是20px;
解决此办法的最简单的方法是,在style中添加:display:inline;
如上面的代码将改为
<div style="float:left;display:inline;margin-left:10px;"></div>
方法2:
可以使用以下办法来书写兼容浏览器的css代码:
第一种
.div{
background:orange;/*ff*/
*background:green!important;/*ie7*/
*background:blue;/*ie6*/
}
第二种
.div{
margin:10px;/*ff*/
*margin:15px;/*ie7*/
_margin:15px;/*ie6*/
}
第三种
#div{color:#333;}/*ff*/
*html#div{color:#666;}/*IE6*/
*+html#div{color:#999;}/*IE7*/
IE6不支持png透明的bug
首先,要在网页中引用js
<!--[if IE 6]>
<script src="http://www.dillerdesign.com/experiment/DD_belatedPNG/DD_belatedPNG_0.0.8a-min.js">
</script>
<script>
DD_belatedPNG.fix('.png_bg');
</script>
<![endif]-->
上面那个js路径是绝对路径,大家最好还是把它下下来,以防网站挂了.
引用之后就是更改第二个<script>里的.png为你要实现效果的选择器.
就比如,你#header引用了一个background,那你上面就要改为:
DD_belatedPNG.fix('#header');
并且它还支持组选择器,如:
DD_belatedPNG.fix('#header,h1,h2,h3,#content');
很简单吧,只要把有透明png的标签或选择器写在里面就行,你所有的png图片在ie6下都会被支持了!!
官网:http://www.dillerdesign.com/experiment/DD_belatedPNG/
本站技术原创栏目文章均为中睿原创或编译,转载请注明:文章来自中睿,本站保留追究责任的权利。