CSS论坛's Archiver

飞翔的蜗牛 发表于 2011-12-15 10:52

css在IE和Firefox中的差别 (部分)

[color=#000][font=Tahoma][size=10.5pt]1[font=宋体]、单位问题[/font][/size][/font][/color]
问题:任何距离的数值[font=Times New Roman]ie[/font][font=宋体]可以不加单位,[/font][font=Times New Roman]ff[/font][font=宋体]必须要求写单位([/font][font=Times New Roman]0[/font][font=宋体]除外) [/font]
解决:写全单位如[font=Times New Roman]padding:0px;[/font]

2[font=宋体]、水平居中[/font]
问题:[font=Times New Roman]div[/font][font=宋体]里的内容,[/font][font=Times New Roman]ie[/font][font=宋体]默认为[/font][font=Times New Roman]center[/font][font=宋体],而[/font][font=Times New Roman]ff[/font][font=宋体]默认[/font][font=Times New Roman]left [/font]
解决:[font=Times New Roman]mairgin:0px auto; [/font]

3[font=宋体]、高度问题[/font]
问题:如果设置了一个[font=Times New Roman]DIV[/font][font=宋体]的高度,当[/font][font=Times New Roman]DIV[/font][font=宋体]里实际内容大于所设高度,[/font][font=Times New Roman]ie[/font][font=宋体]会自动拉伸以适应[/font][font=Times New Roman]DIV[/font][font=宋体]容器大小,[/font][font=Times New Roman]ff[/font][font=宋体]会固定[/font][font=Times New Roman]DIV[/font][font=宋体]的告诉,超过部分超出[/font][font=Times New Roman]DIV[/font][font=宋体]底线以外,出现和下面的内容重叠的现象[/font]
解决:控制恰当的高度,或者不写,让浏览器自动调节高度,或者设置[font=Times New Roman]overflow:hidden;[/font]

4[font=宋体]、[/font][font=Times New Roman]clear:both;[/font]
问题:如果上面用[font=Times New Roman]float[/font][font=宋体]控制了[/font][font=Times New Roman]n[/font][font=宋体]列[/font][font=Times New Roman]DIV[/font][font=宋体],下面[/font][font=Times New Roman]ie[/font][font=宋体]会自动检测自动排列,[/font][font=Times New Roman]ff[/font][font=宋体]则可能很不老实,到处乱动[/font]
解决:[font=Times New Roman]float[/font][font=宋体]结束后的下一个标签加[/font][font=Times New Roman]clear:both;[/font][font=宋体]以结束[/font][font=Times New Roman]float[/font][font=宋体]的控制[/font]

5[font=宋体]、最大[/font][font=Times New Roman]/[/font][font=宋体]小宽度问题[/font]
问题:[font=Times New Roman]min-width,max-width[/font][font=宋体]只是[/font][font=Times New Roman]ff[/font][font=宋体]的命令,如何让[/font][font=Times New Roman]ie[/font][font=宋体]实现同样的效果[/font]
解决:[font=Times New Roman]ie[/font][font=宋体]不认识[/font][font=Times New Roman]min-[/font][font=宋体]和[/font][font=Times New Roman]max-[/font][font=宋体],实际[/font][font=Times New Roman]ie[/font][font=宋体]认为[/font][font=Times New Roman]min-width[/font][font=宋体]、[/font][font=Times New Roman]max-width[/font][font=宋体]和[/font][font=Times New Roman]width[/font][font=宋体]效果一样,可以用下面方法解决[/font]
#cctext{
min-width: 700px;
max-width: 1000px;
width:expression(document.body.clientWidth<700 ? "700px" : document.body.clientWidth>1000 ? "1000px" : "auto");
}

6[font=宋体]、[/font][font=Times New Roman]!important[/font][font=宋体]支持[/font]
问题:[font=Times New Roman]ff[/font][font=宋体]支持[/font][font=Times New Roman]ie[/font][font=宋体]不支持[/font]
解决:无。[font=Times New Roman]ie[/font][font=宋体]会忽略。[/font]

7[font=宋体]、游标状态[/font]
问题:[font=Times New Roman]cursor:hand;[/font][font=宋体]仅[/font][font=Times New Roman]ie[/font][font=宋体]支持,显示手指状态[/font]
解决:使用[font=Times New Roman]cursor:pointer;ie[/font][font=宋体]和[/font][font=Times New Roman]ff[/font][font=宋体]都支持[/font]

8[font=宋体]、实际像素[/font]
IE/Opera[font=宋体]:对象的实际宽度 [/font][font=Times New Roman]= (margin-left) + width + (margin-right)[/font]
Firefox/Mozilla[font=宋体]:对象的实际宽度[/font][font=Times New Roman]= (margin-left) + (border-left-width) + (padding- left) + width + (padding-right) + (border-right-width) + (margin-right)[/font]
所以排列好及列的表格时[font=Times New Roman]ie[/font][font=宋体]和[/font][font=Times New Roman]ff[/font][font=宋体]显示宽度稍有区别[/font]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.