解决各大浏览器兼容问题hack方法总结
生活随笔
收集整理的這篇文章主要介紹了
解决各大浏览器兼容问题hack方法总结
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
解決各大瀏覽器兼容問題hack,IE6/ IE7/ IE8/ IE9/ Firefox/ Opera/ Webkit/ Chrome/ Safari.
方法一
1 color:red; /* 所有瀏覽器都支持 */ 2 color:red !important; /* 除IE6外 */ 3 _color:red; /* IE6支持 */ 4 *color:red; /* IE6、IE7支持 */ 5 +color:red; /*IE7支持*/ 6 *+color:red; /* IE7支持 */ 7 color:red\9; /* IE6、IE7、IE8、IE9支持 */ 8 color:red\; /* 針對所有IE */ 9 color:red\0; /* IE8、IE9支持 */ 10 color:red\9\0; /*IE9支持*/ 11 /* webkit and opera */ 12 @media all and (min-width: 0px){ div{color:red;} } 13 /* webkit */ 14 @media screen and (-webkit-min-device-pixel-ratio:0){ div{color:red;} } 15 /* opera */ 16 @media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel- 17 18 ratio:0) { div{color:red;} } 19 /* firefox * / 20 @-moz-document url-prefix(){ div{color:red;}} /* all firefox */ 21 22 html>/**/body div, x:-moz-any-link, x:default {color:red;} /* newest firefox */ 23 } 24 body:nth-of-type(1) p{color:red;} /* Chrome、Safari支持 */方法二
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]--> <!--[if IE 7 ]> <html class="ie7"> <![endif]--> <!--[if IE 8 ]> <html class="ie8"> <![endif]--> <!--[if IE 9 ]> <html class="ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <html> <!--<![endif]--> <!–[if IE 7]> = 等于 IE7 <!–[if lt IE 8]> = 小于 IE8(就是 IE7 或以下了啦) <!–[if gte IE 8]> = 大于或等于 IE8 <meta http-equiv="x-ua-compatible" content="ie=7" /> 把這段代碼放到<head>里面,在ie8里面的頁面解析起來就跟ie7一模一樣的了 <!–[if IE]> <link rel=”stylesheet” href=”/ie-all.css” type=”text/css” media=”screen” /> <![endif]–><!–[if lt IE 8]> <link rel=”stylesheet” href=”/ie.css” type=”text/css” media=”screen” /> <![endif]–><!–[if IE 7]> <link rel=”stylesheet” href=”/ie7.css” type=”text/css” media=”screen” /> <![endif]–><!–[if IE 6]> <link rel=”stylesheet” href=”/ie6.css” type=”text/css” media=”screen” /> <![endif]–>
上面提到兩種解決各大瀏覽器兼容問題的辦法,即:判斷瀏覽器針對不同瀏覽器寫不同的CSS文件和在同一個CSS文件中用各種瀏覽器的hack解決。兩種辦法各有利弊,選擇的時候應(yīng)根據(jù)具體需要采用最適當?shù)姆椒ā?/span>
轉(zhuǎn)載于:https://www.cnblogs.com/xiaoyunxiao/archive/2012/04/03/2430958.html
總結(jié)
以上是生活随笔為你收集整理的解决各大浏览器兼容问题hack方法总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows 7备份、还原功能详解
- 下一篇: 转存储过程实现分页1