整理IE低版本浏览器的bug

IE6双倍距的问题

问题: 当浮动元素设置margin边距时,边距会加倍。
解决方法:是给浮动元素加上display:inline属性

IE6图片下方有空间隙

问题:图片的下方默认的空隙
解决方案: 给img设置 display:block属性

IE63像素偏移BUG

问题:当浮动元素与非浮动元素相邻(注意这里的相邻可以是纵向的也可以是横向的)时,这个3像素的Bug就会出现,它会偏移3像素。实际表现就是两个元素之间产生了一道缝隙!
解决方案:将两个元素都浮动就OK了。此BUG深层的原因是非浮动元素的layout未触发,所以这里只要是能够触发layout的css都可以解决问题。

相对位置和溢出隐藏

问题:当父元素的overflow被设置成hidden并且子元素被设置成position:relative。
解决方案:为父元素增加position:relative;

IE的最小高度

问题:没有最小高度的概念
解决方案:IE忽略min-height属性。采用这种暴力的方式解决:

selector {
   min-height:500px;
   height:auto !important;
   height:500px;
}

IE6,7失效的margin-left/right

问题;

<div class="wrap">
    <div class="cont">banggan</div>
</div>
wrap{background:#eee;border:1px solid #ccc;}
cont{border-bottom:2px solid #aaa;margin:0 100px;height:30px;}

解决方案:触发.warp的layout就可以了。具体的比如:给.warp加上zoom:1或者width等等。

PNG透明

所以如果你想要使用透明图像并且GIF不能给你想要的质量,你会需要这个对PNG的hack。你必须意识到,如果你使用一张PNG图像作为背景,你将不能设置背景的位置。解决方案:

img {
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(...);

禁用IE默认垂直滚动条

默认情况下,即使内容适合窗口大小,IE(译注:IE6/7)也会显示垂直滚动条。你可以使用overflow:auto,让滚动条只在你需要时出现

:hover伪类

IE只支持a元素的 :hover伪类。使用jQuery的hover event来达到相同效果。

IE中 Iframe透明背景

在firefox和safari里你应该不会遇到这个问题因为默认情况下,iframe的背景被设置为transparent,但是在IE里,却不是如此。你需要用到allowTransparency 属性并且加入下面的CSS代码来达成目的。

/* in the iframe element */
<iframe src="content.html" allowtransparency="true">
</iframe>

/* in the iframe docuement, in this case content.html */
body {
    background-color:transparent;
}

其他

  • input[button | submit] 不能用 margin:0 auto; 居中,为input添加width
  • body{overflow:hidden;}没有去掉滚动条,设置html{overflow:hidden;}
  • hasLayout的标签拥有高度,*height:0;_overflow:hidden;
  • :hover伪类不能改变有position:absolute的子级元素的left/top值,把top/left的值设置成除0%外的所有百分值;或添加一个margin-[所有方向]除0外的所有值,包括0%
  • margin:0 auto; 不能让block元素水平居中,给block元素添加一个width
  • form>[hasLayout]元素有margin-left时,子元素中的[input | textarea] 出现2×margin-left,form > [hasLayout 元素]{margin-left:宽度;}form div{*margin-left:宽度÷2;}
  • 当border-width有1条<边3条时被设置成dotted时,1px的边dotted显示成dashed,不在同一个元素上使用不同宽度的 dotted
  • :focus + selector {} 选择器失效,在失效选择器后面添加一个空选择器, :focus{}
  • 列表中混乱的浮动:在list中浮动图片时,图片出现溢出正常位置;或没有list-style,用背景图片替换list-style
  • th 不会自动继承上级元素的 text-align,给th添加text-align:inherit;
  • :hover 时若background-color为#fff, 失效,把background-color改成background。或者,非#fff || #ffffff

猜你喜欢

转载自blog.csdn.net/bangbanggangan/article/details/81590894