區別IE6與FF:
background:orange;*background:blue;
區別IE6與IE7:
background:green !important;background:blue;
區別IE7與FF:
background:orange; *background:green;
區別FF,IE7,IE6:
background:orange;*background:green !important;*background:blue;
IE7,IE8兼容:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
2. IE專用的條件注釋
<!--其他瀏覽器 -->
<link rel="stylesheet" type="text/css" href="css.css" />
<!--[if IE 7]>
<!-- 適合于IE7 -->
<link rel="stylesheet" type="text/css" href="ie7.css" />
<![endif]-->
<!--[if lte IE 6]>
<!-- 適合于IE6及一下 -->
<link rel="stylesheet" type="text/css" href="ie.css" />
<![endif]-->
3. 幾個瀏覽器對實際像素的解釋
IE/Opera:對象的實際寬度 = (margin-left) + width + (margin-right)
Firefox/Mozilla:對象的實際寬度= (margin-left) + (border-left-width) + (padding- left) + width + (padding-right) + (border-right-width) + (margin-right)
4. 鼠標手勢問題:FireFox的cursor屬性不支持hand,但是支持pointer,IE兩個都支持;所以為了兼容都用pointer
5. FireFox中設置HTML標簽的Style屬性時,所有位置、寬高和尺寸值必須后跟px,IE也支持此寫法,因此統一加px單位。如 Obj.Style.Height = imgObj.Style.Height + ‘px';
6. FireFox無法解析簡寫的padding屬性設置,如padding 5px 4px 3px 1px;必須改為 padding-top:5px; padding-right:4px; padding-bottom:3px; padding-left:1px0;
7. 消除ul、ol等列表的縮進時,樣式應寫成:list-style:none;margin:0px;padding:0px;其中margin屬性對IE有效,padding屬性對FireFox有效
8. CSS控制透明:IE:filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=60); FireFox:opacity:0.6;
9. CSS控制圓角:IE:不支持圓角;
FireFox: -moz-border-radius:4px;或
-moz-border-radius-topleft:4px;
-moz-border-radius-topright:4px;
-moz-border-radius-bottomleft:4px;
-moz-border-radius- bottomright:4px;
10. CSS雙線凹凸邊框:IE:border:2px outset;
FireFox:
-moz-border-top-colors: #d4d0c8 white;
-moz-border-left-colors: #d4d0c8 white;
-moz-border-right-colors:#404040 #808080;
-moz-border-bottom-colors:#404040 #808080;
11. IE支持CSS方法cursor:url()自定義光標樣式文件和滾動條顏色風格;FireFox對以上兩者均不支持
12. IE有Select控件永遠處于最上層的bug,且所有CSS對Select控件都不起作用
13. IE支持Form中的Label標簽,包括圖片和文字內容;FireFox不支持包含圖片的Label,點擊圖片不能讓標記 label for 的Radio或CheckBox產生效果
14. FireFox中的TextArea不支持onScroll事件
15. FireFox不支持display的inline和block
16. FireFox對Div設置margin-left, margin-right為auto時已經居中, IE中不行
17. FireFox對Body設置text-align時, Div需要設置margin: auto(主要是margin-left margin-right) 方可居中
18. 對超鏈接的CSS樣式設置最好遵從這樣的順序:L-V-H-A。即
<style type="text/css">
<!--
a:link {}
a:visited {}
a:hover {}
a:active {}
-->
</style>
這樣可以避免一些訪問過后的超鏈接就不具備hover和active樣式了
19. IE中設置長段落自動換行在CSS中設置word-wrap:break-word;FireFox中使用JS插入 的方法來實現,具體代碼如下:
<script type="text/javascript">
/* <![CDATA[ */
function toBreakWord(el, intLen){
var obj=document.getElementById(el);
var strContent=obj.innerHTML;
var strTemp="";
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+" ";
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+=" "+strContent;
obj.innerHTML=strTemp;
}
if(document.getElementById && !document.all) toBreakWord("div_id", 37);
/* ]]> */
</script>
20. 在子容器加了浮動屬性后,該容器將不能自動撐開
解決方法:在標簽結束后下一個標簽中加上一個清除浮動的CSS clear:both;
精彩內容,請點擊下一頁!