目前主流浏览器的兼容性做的都比较好了,本文主要针对IE6,7的不兼容问题进行解决。
1.有浮动存在时,计算一定要精确,不要让内容的宽高超出我们所设置的宽高,IE6下,内容会撑开设置好的高度。
解决方法:给对应的父级加overflow:hidden;但是会有部分被隐藏掉,最好是精确计算宽高再设定
eg:(ie会撑开)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <span style= "color: #008080;" > 1 <span style= "color: #0000ff;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 2 <span style= "color: #800000;" >.box<span style= "color: #000000;" >{<span style= "color: #ff0000;" > width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >400px<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 3 <span style= "color: #800000;" >.left<span style= "color: #000000;" >{<span style= "color: #ff0000;" > width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >200px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >300px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >red<span style= "color: #000000;" >;<span style= "color: #ff0000;" >float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >left<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 4 <span style= "color: #800000;" >.right<span style= "color: #000000;" >{<span style= "color: #ff0000;" > width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >200px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >right<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 5 <span style= "color: #800000;" >.div<span style= "color: #000000;" >{<span style= "color: #ff0000;" >width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >180px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >180px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >blue<span style= "color: #000000;" >;<span style= "color: #ff0000;" >padding<span style= "color: #000000;" >:<span style= "color: #0000ff;" >15px<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 6 <span style= "color: #008000;" >
<span style= "color: #008080;" >10 <span style= "color: #0000ff;" ><span style= "color: #800000;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >11 <span style= "color: #0000ff;" ><span style= "color: #800000;" >head<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >12 <span style= "color: #0000ff;" >body<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >13 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "box" <span style= "color: #0000ff;" >>
<span style= "color: #008080;" >14 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "left" <span style= "color: #0000ff;" >><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >15 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "right" <span style= "color: #0000ff;" >>
<span style= "color: #008080;" >16 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "div" <span style= "color: #0000ff;" >><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >17 <span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >18 <span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >19 <span style= "color: #0000ff;" ><span style= "color: #800000;" >body<span style= "color: #0000ff;" >></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
|
登录后复制
2. 在IE6下有元素浮动时,如果宽度需要由内容撑开,就给里边的块元素都加浮动,正常浏览器不用加浮动。
eg:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <span style= "color: #008080;" > 1 <span style= "color: #0000ff;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 2 <span style= "color: #800000;" >.box<span style= "color: #000000;" >{<span style= "color: #ff0000;" > width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >400px<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 3 <span style= "color: #800000;" >.left<span style= "color: #000000;" >{<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >red<span style= "color: #000000;" >;<span style= "color: #ff0000;" >float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >left<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 4 <span style= "color: #800000;" >.right<span style= "color: #000000;" >{<span style= "color: #ff0000;" >float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >right<span style= "color: #000000;" >;<span style= "color: #ff0000;" > background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >blue<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 5 <span style= "color: #800000;" >h3<span style= "color: #000000;" >{<span style= "color: #ff0000;" >margin<span style= "color: #000000;" >:<span style= "color: #0000ff;" >0<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >30px<span style= "color: #000000;" >;<span style= "color: #ff0000;" > float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >left<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 6 <span style= "color: #008000;" >
<span style= "color: #008080;" > 9 <span style= "color: #0000ff;" ><span style= "color: #800000;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >10 <span style= "color: #0000ff;" ><span style= "color: #800000;" >head<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >11 <span style= "color: #0000ff;" >body<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >12 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "box" <span style= "color: #0000ff;" >>
<span style= "color: #008080;" >13 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "left" <span style= "color: #0000ff;" >>
<span style= "color: #008080;" >14 <span style= "color: #0000ff;" >h3<span style= "color: #0000ff;" >>左侧<span style= "color: #0000ff;" ><span style= "color: #800000;" >h3<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >15 <span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >16 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "right" <span style= "color: #0000ff;" >>
<span style= "color: #008080;" >17 <span style= "color: #0000ff;" >h3<span style= "color: #0000ff;" >>右侧<span style= "color: #0000ff;" ><span style= "color: #800000;" >h3<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >18 <span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >19 <span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >20 <span style= "color: #0000ff;" ><span style= "color: #800000;" >body<span style= "color: #0000ff;" >></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
|
登录后复制
3. 在IE6下元素的高度的小于19px的时候,会被当做19px来处理
解决办法:添加overflow:hidden;
4. 在IE6下border:1px dotted #000;中,dotted不支持,会以虚线的方式的出现。
解决方法:切背景平铺
5. 在所有浏览器中子元素的margin-top,margin-bottom值会传递给父级;
解决办法:
a:给父级都添加浮动(或者给子级添加浮动也能解决margin-top问题,但是margin左右值会出现双倍的值,也就是双边据bug问题,下面会讲);
b:给父级添加position:relative;(或position:absolute;但是会脱离文档流)
c:添加display:inline-block; 正常浏览器,可行,但是IE,7下,块元素不支持display:inline-block;
d: 给附件添加border属性,例如border:1px solid red; 正常浏览器可行,在IE6下必须再给父级添加zoom:1;
eg:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <span style= "color: #008080;" > 1 <span style= "color: #0000ff;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 2 <span style= "color: #800000;" >body<span style= "color: #000000;" >{<span style= "color: #ff0000;" >margin<span style= "color: #000000;" >:<span style= "color: #0000ff;" >0<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 3 <span style= "color: #800000;" >.box<span style= "color: #000000;" >{<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >blue<span style= "color: #000000;" >;<span style= "color: #ff0000;" >border<span style= "color: #000000;" >:<span style= "color: #0000ff;" >1px solid #000<span style= "color: #000000;" >;<span style= "color: #ff0000;" > zoom<span style= "color: #000000;" >:<span style= "color: #0000ff;" >1<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 4 <span style= "color: #800000;" >.div<span style= "color: #000000;" >{<span style= "color: #ff0000;" >width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >200px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >200px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >red<span style= "color: #000000;" >;<span style= "color: #ff0000;" >margin<span style= "color: #000000;" >:<span style= "color: #0000ff;" >100px<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 5 <span style= "color: #008000;" >
<span style= "color: #008080;" >12 <span style= "color: #0000ff;" ><span style= "color: #800000;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >13 <span style= "color: #0000ff;" ><span style= "color: #800000;" >head<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >14 <span style= "color: #0000ff;" >body<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >15 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "box" <span style= "color: #0000ff;" >>
<span style= "color: #008080;" >16 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "div" <span style= "color: #0000ff;" >><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >17 <span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >18 <span style= "color: #0000ff;" ><span style= "color: #800000;" >body<span style= "color: #0000ff;" >><br><br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
|
登录后复制
6. 在IE6下,块元素有浮动和和横向的margin值 ,横向的margin值会被放大成两倍。
解决办法:添加display:inline;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <span style= "color: #008080;" > 1 <span style= "color: #0000ff;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 2 <span style= "color: #800000;" >.box<span style= "color: #000000;" >{<span style= "color: #ff0000;" > float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >left<span style= "color: #000000;" >;<span style= "color: #ff0000;" >border<span style= "color: #000000;" >:<span style= "color: #0000ff;" >10px solid #000<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 3 <span style= "color: #800000;" >.box div<span style= "color: #000000;" >{<span style= "color: #ff0000;" >width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >100px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >100px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >Red<span style= "color: #000000;" >;<span style= "color: #ff0000;" >margin-right<span style= "color: #000000;" >:<span style= "color: #0000ff;" >20px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >border<span style= "color: #000000;" >:<span style= "color: #0000ff;" >5px solid #ccc<span style= "color: #000000;" >;<span style= "color: #ff0000;" > float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >left<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 4 <span style= "color: #008000;" >
<span style= "color: #008080;" > 9 <span style= "color: #0000ff;" ><span style= "color: #800000;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >10 <span style= "color: #0000ff;" ><span style= "color: #800000;" >head<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >11 <span style= "color: #0000ff;" >body<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >12 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "box" <span style= "color: #0000ff;" >>
<span style= "color: #008080;" >13 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>1<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >14 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>2<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >15 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>3<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >16 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>4<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >17 <span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >18 <span style= "color: #0000ff;" ><span style= "color: #800000;" >body<span style= "color: #0000ff;" >><br><br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
|
登录后复制
7. 在IE6,7下,li自身没浮动,但是li的内容有浮动,li下边就会产生一个间隙
解决办法:1.给li加浮动
2.给li加vertical-align:top;
注意:当IE6下最小高度问题,和 li的间隙问题共存的时候, 给li加浮动才能解决。
eg:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <span style= "color: #008080;" > 1 <span style= "color: #0000ff;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 2 <span style= "color: #800000;" >ul<span style= "color: #000000;" >{<span style= "color: #ff0000;" >margin<span style= "color: #000000;" >:<span style= "color: #0000ff;" >0<span style= "color: #000000;" >;<span style= "color: #ff0000;" >padding<span style= "color: #000000;" >:<span style= "color: #0000ff;" >0<span style= "color: #000000;" >;<span style= "color: #ff0000;" >width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >302px<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 3 <span style= "color: #800000;" >li<span style= "color: #000000;" >{<span style= "color: #ff0000;" > list-style<span style= "color: #000000;" >:<span style= "color: #0000ff;" >none<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >30px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >border<span style= "color: #000000;" >:<span style= "color: #0000ff;" >1px solid #000<span style= "color: #000000;" >;<span style= "color: #ff0000;" > vertical-align<span style= "color: #000000;" >:<span style= "color: #0000ff;" >top<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 4 <span style= "color: #800000;" >a<span style= "color: #000000;" >{<span style= "color: #ff0000;" >width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >100px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >left<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >30px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >Red<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 5 <span style= "color: #800000;" >span<span style= "color: #000000;" >{<span style= "color: #ff0000;" >width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >100px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >right<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >30px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >blue<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 6 <span style= "color: #008000;" >
<span style= "color: #008080;" >12 <span style= "color: #0000ff;" ><span style= "color: #800000;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >13 <span style= "color: #0000ff;" ><span style= "color: #800000;" >head<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >14 <span style= "color: #0000ff;" >body<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >15 <span style= "color: #0000ff;" >ul<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >16 <span style= "color: #0000ff;" >li<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >17 <span style= "color: #0000ff;" >a <span style= "color: #ff0000;" >href<span style= "color: #0000ff;" >= "#" <span style= "color: #0000ff;" >><span style= "color: #800000;" >a<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >18 <span style= "color: #0000ff;" >span<span style= "color: #0000ff;" >><span style= "color: #800000;" >span<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >19 <span style= "color: #0000ff;" ><span style= "color: #800000;" >li<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >20 <span style= "color: #0000ff;" >li<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >21 <span style= "color: #0000ff;" >a <span style= "color: #ff0000;" >href<span style= "color: #0000ff;" >= "#" <span style= "color: #0000ff;" >><span style= "color: #800000;" >a<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >22 <span style= "color: #0000ff;" >span<span style= "color: #0000ff;" >><span style= "color: #800000;" >span<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >23 <span style= "color: #0000ff;" ><span style= "color: #800000;" >li<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >24 <span style= "color: #0000ff;" >li<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >25 <span style= "color: #0000ff;" >a <span style= "color: #ff0000;" >href<span style= "color: #0000ff;" >= "#" <span style= "color: #0000ff;" >><span style= "color: #800000;" >a<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >26 <span style= "color: #0000ff;" >span<span style= "color: #0000ff;" >><span style= "color: #800000;" >span<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >27 <span style= "color: #0000ff;" ><span style= "color: #800000;" >li<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >28 <span style= "color: #0000ff;" ><span style= "color: #800000;" >ul<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >29 <span style= "color: #0000ff;" ><span style= "color: #800000;" >body<span style= "color: #0000ff;" >><br><br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
|
登录后复制
8.当一行子元素占有的宽度之和和父级的宽度相差超过3px,或者有不满行状态的时候,最后一行子元素的下margin在IE6下就会失效
解决方法:额,还没发现
eg:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <span style= "color: #008080;" > 1 <span style= "color: #0000ff;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 2 <span style= "color: #800000;" >.box<span style= "color: #000000;" >{<span style= "color: #ff0000;" >border<span style= "color: #000000;" >:<span style= "color: #0000ff;" >10px solid #000<span style= "color: #000000;" >;<span style= "color: #ff0000;" >width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >600px<span style= "color: #000000;" >; <span style= "color: #008000;" > <span style= "color: #ff0000;" > overflow<span style= "color: #000000;" >:<span style= "color: #0000ff;" >hidden<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 3 <span style= "color: #800000;" >.box div<span style= "color: #000000;" >{<span style= "color: #ff0000;" >width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >100px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >100px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >Red<span style= "color: #000000;" >;<span style= "color: #ff0000;" >margin<span style= "color: #000000;" >:<span style= "color: #0000ff;" >20px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >border<span style= "color: #000000;" >:<span style= "color: #0000ff;" >5px solid #ccc<span style= "color: #000000;" >;<span style= "color: #ff0000;" > float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >left<span style= "color: #000000;" >;<span style= "color: #ff0000;" > display<span style= "color: #000000;" >:<span style= "color: #0000ff;" >inline<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 4 <span style= "color: #008000;" >
<span style= "color: #008080;" > 7 <span style= "color: #0000ff;" ><span style= "color: #800000;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 8 <span style= "color: #0000ff;" ><span style= "color: #800000;" >head<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 9 <span style= "color: #0000ff;" >body<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >10 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "box" <span style= "color: #0000ff;" >>
<span style= "color: #008080;" >11 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>1<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >12 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>2<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >13 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>3<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >14 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>4<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >15 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>1<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >16 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>2<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >17 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>3<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >18 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>4<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >19 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>1<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >20 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>2<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >21 <span style= "color: #0000ff;" >div<span style= "color: #0000ff;" >>3<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >22 <span style= "color: #008000;" ><!--<span style= "color: #008000;" > <div>4</div> <span style= "color: #008000;" >-->
<span style= "color: #008080;" >23 <span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >><br><br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
|
登录后复制
9. 在IE6下的文字溢出BUG。即:子元素的宽度和父级的宽度相差小于3px的时候,或者两个浮动元素中间有注释或者内嵌元素的时候,IE6下文字溢出
解决办法:用div把注释或者内嵌元素用div包起来。
eg:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <span style= "color: #008080;" > 1 <span style= "color: #0000ff;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 2 <span style= "color: #800000;" >.box<span style= "color: #000000;" >{<span style= "color: #ff0000;" > width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >400px<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 3 <span style= "color: #800000;" >.left<span style= "color: #000000;" >{<span style= "color: #ff0000;" >float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >left<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 4 <span style= "color: #800000;" >.right<span style= "color: #000000;" >{<span style= "color: #ff0000;" >width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >400px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >right<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 5 <span style= "color: #0000ff;" ><span style= "color: #800000;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 6 <span style= "color: #0000ff;" ><span style= "color: #800000;" >head<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 7 <span style= "color: #0000ff;" >body<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 8 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "box" <span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 9 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "left" <span style= "color: #0000ff;" >><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >10 <span style= "color: #008000;" ><!--<span style= "color: #008000;" > IE6下的文字溢出BUG <span style= "color: #008000;" >--><span style= "color: #0000ff;" >span<span style= "color: #0000ff;" >><span style= "color: #800000;" >span<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >11 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "right" <span style= "color: #0000ff;" >><span style= "color: #ff0000;" >↓哈哈哈哈哈哈哈哈哈哈<span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >12 <span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >13 <span style= "color: #008000;" ><!--
<span style= "color: #008080;" >14 <span style= "color: #008000;" > 在IE6下的文字溢出BUG
<span style= "color: #008080;" >15
<span style= "color: #008080;" >16 <span style= "color: #008000;" > 子元素的宽度和父级的宽度相差小于3px的时候,两个浮动元素中间有注释或者内嵌元素
<span style= "color: #008080;" >17
<span style= "color: #008080;" >18 <span style= "color: #008000;" > 解决办法:用div把注释或者内嵌元素用div包起来
<span style= "color: #008080;" >19 <span style= "color: #008000;" >-->
<span style= "color: #008080;" >20 <span style= "color: #0000ff;" ><span style= "color: #800000;" >body<span style= "color: #0000ff;" >><br><br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
|
登录后复制
10. 当浮动元素和绝对定位元素是并列关系的时候,在IE6下绝对定位元素会消失。
解决办法: 给定位元素外面包个div。
eg:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <span style= "color: #008080;" > 1 <span style= "color: #0000ff;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 2 <span style= "color: #800000;" >.box<span style= "color: #000000;" >{<span style= "color: #ff0000;" > width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >200px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >200px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >border<span style= "color: #000000;" >:<span style= "color: #0000ff;" >1px solid #000<span style= "color: #000000;" >;<span style= "color: #ff0000;" > position<span style= "color: #000000;" >:<span style= "color: #0000ff;" >relative<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 3 <span style= "color: #800000;" >span<span style= "color: #000000;" >{<span style= "color: #ff0000;" >width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >50px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >50px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >yellow<span style= "color: #000000;" >;<span style= "color: #ff0000;" > position<span style= "color: #000000;" >:<span style= "color: #0000ff;" >absolute<span style= "color: #000000;" >;<span style= "color: #ff0000;" >right<span style= "color: #000000;" >:<span style= "color: #0000ff;" >-20px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >top<span style= "color: #000000;" >:<span style= "color: #0000ff;" >0<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 4 <span style= "color: #800000;" >ul<span style= "color: #000000;" >{<span style= "color: #ff0000;" >width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >150px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >150px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >Red<span style= "color: #000000;" >;<span style= "color: #ff0000;" >margin<span style= "color: #000000;" >:<span style= "color: #0000ff;" >0 0 0 50px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >padding<span style= "color: #000000;" >:<span style= "color: #0000ff;" >0<span style= "color: #000000;" >;<span style= "color: #ff0000;" > float<span style= "color: #000000;" >:<span style= "color: #0000ff;" >left<span style= "color: #000000;" >;<span style= "color: #ff0000;" > display<span style= "color: #000000;" >:<span style= "color: #0000ff;" >inline<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 5 <span style= "color: #008000;" >
<span style= "color: #008080;" >10 <span style= "color: #0000ff;" ><span style= "color: #800000;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >11 <span style= "color: #0000ff;" ><span style= "color: #800000;" >head<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >12 <span style= "color: #0000ff;" >body<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >13 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "box" <span style= "color: #0000ff;" >>
<span style= "color: #008080;" >14 <span style= "color: #0000ff;" >ul<span style= "color: #0000ff;" >><span style= "color: #800000;" >ul<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >15 <span style= "color: #0000ff;" >span<span style= "color: #0000ff;" >><span style= "color: #800000;" >span<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >16 <span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >><br><br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
|
登录后复制
11. 在IE6,7下,子元素有相对定位的话,父级的overflow包不住子元素。
解决办法: 给父级也加相对定位 position:relative;。
eg:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <span style= "color: #008080;" > 1 <span style= "color: #0000ff;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" > 2 <span style= "color: #800000;" >.box<span style= "color: #000000;" >{<span style= "color: #ff0000;" > width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >200px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >200px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >border<span style= "color: #000000;" >:<span style= "color: #0000ff;" >1px solid #000<span style= "color: #000000;" >;<span style= "color: #ff0000;" > overflow<span style= "color: #000000;" >:<span style= "color: #0000ff;" >hidden<span style= "color: #000000;" >; <span style= "color: #008000;" > <span style= "color: #000000;" >}
<span style= "color: #008080;" > 3 <span style= "color: #800000;" >.div<span style= "color: #000000;" >{<span style= "color: #ff0000;" > width<span style= "color: #000000;" >:<span style= "color: #0000ff;" >150px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >height<span style= "color: #000000;" >:<span style= "color: #0000ff;" >300px<span style= "color: #000000;" >;<span style= "color: #ff0000;" >background<span style= "color: #000000;" >:<span style= "color: #0000ff;" >yellow<span style= "color: #000000;" >;<span style= "color: #ff0000;" > position<span style= "color: #000000;" >:<span style= "color: #0000ff;" >relative<span style= "color: #000000;" >;<span style= "color: #000000;" >}
<span style= "color: #008080;" > 4 <span style= "color: #008000;" >
<span style= "color: #008080;" > 9 <span style= "color: #0000ff;" ><span style= "color: #800000;" >style<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >10 <span style= "color: #0000ff;" ><span style= "color: #800000;" >head<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >11 <span style= "color: #0000ff;" >body<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >12 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "box" <span style= "color: #0000ff;" >>
<span style= "color: #008080;" >13 <span style= "color: #0000ff;" >div <span style= "color: #ff0000;" > class <span style= "color: #0000ff;" >= "div" <span style= "color: #0000ff;" >><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >14 <span style= "color: #0000ff;" ><span style= "color: #800000;" >div<span style= "color: #0000ff;" >>
<span style= "color: #008080;" >15 <span style= "color: #0000ff;" ><span style= "color: #800000;" >body<span style= "color: #0000ff;" >><br><br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
|
登录后复制
12. 在IE6下绝对定位元素的父级宽高是奇数的时候,元素的right值和bottom值会有1px的偏差.
解决办法: 尽量用偶数,还没发现别的方法。
13. 在IE6下,position:fixed; 是没有效果的。
解决方法:用js来控制吧。。。
14. 在IE6,7下输入类型的表单控件上下各有1px的间隙。
解决办法:给input加浮动,或者是绝对定位。
15. 在IE6,7下输入类型的表单控件加border:none;会发现border还在,
解决办法: 重置input的背景,如input{background:#fff;}; 或者使用border:0;或border:0 none;
16. 在IE6,7下输入类型的表单控件输入文字的时候,其背景图片会跟着一块移动 。
解决办法: 把背景加给父级。
17. 更简洁的css清理浮动方式:
方法1:
/* 清理浮动 */
.clearfix:after {
visibility:hidden;
display:block;
font-size:0;
content:" ";
clear:both;
height:0;
}
.clearfix {
zoom:1;
}
方法2:
在父元素加代码:overflow:auto; zoom:1;
18. css强制换行与强制不换行:
/* 禁止换行 */ .nowrap{word-break:keep-all;white-space:nowrap;}
/* 强制换行 */ .break{word-break:break-all;}
19. 超链接样式的设置:
a:link {color: #FF0000} /* 未访问的链接 */
a:visited {color: #00FF00} /* 已访问的链接 */
a:hover {color: #FF00FF} /* 鼠标移动到链接上 */
a:active {color: #0000FF} /* 选定的链接 */
格式化标签的默认样式;
20. css/js在线压缩:(有YUI Compressor工具)
http://ganquan.info/yui/?hl=zh-CN
21. 当一行固定宽度,且显示不下内容,则加省略号:
{white-space:nowrap;
text-overflow:ellipsis; /* for internet explorer */
overflow:hidden;
width:190px;
display:block;
text-overflow:ellipsis}
text-overflow:ellipsis(代表三个点的省略号)
22. 浏览器兼容性
margin-bottom:40px; /*ff的属性*/
margin-bottom:140px\9; /* IE6/7/8的属性 */
color:red\0; /* IE8支持 */
*margin-bottom:450px; /*IE6/7的属性*/
_margin-bottom:450px; /*IE6/7的属性*/