各種瀏覽器css hack

來源:互聯網
上載者:User

標籤:style   color   ar   div   ef   as   c   css   ld   

你在寫css時樣式表加上瀏覽器標識符就行了,各瀏覽器區別如下:

IE都能識別*,標準瀏覽器(如FF)不能識別*;
IE6能識別*,但不能識別 !important;
IE7能識別*,也能識別 !important;
IE8能識別\0,不能識別*,+,_,*加!important;
FF不能識別*,但能識別 !important;
例如style=”*width:10px!important; width:20px;”
這樣在IE6下寬度為10px,在IE7下寬度時20px

其中還有三種寫法:

1種:
width:100px; /* FireFox及其他瀏覽器 */
width:200px\0; /* IE8能識別\0*/
*width:300px!important; /* ,IE7 既能能識別*號,也能識別important */
*width:400px; /* IE6也能識別*號 */
/*注意順序 */

2種:
width:100px; /* FireFox及其他瀏覽器 */
width:200px\0; /* IE8能識別\0*/
*width:300px; /* IE7也能識別*號 */
_width:400px; /* IE6能識別底線*/
/*注意順序 */

3種:
width:100px; /* FireFox及其他瀏覽器 */
width:200px\0; /* IE8能識別\0*/
+width:300px; /* +只識別IE7 */
_width:400px; /* IE6能識別底線*/
/*注意順序 */

1..color1{ color:#F00; color/*\**/:#00F /*\**/}/*IE6,IE7,IE8,FF,OP,SA識別*/
2..color2{ color:#F00; color /*\**/:#00F /*\9**/}/*IE7,IE8,FF,OP,SA識別*/
3..color3{ color:#F00; color/*\**/:#00F \9}/*IE6,IE7,IE8識別*/
4..color4{ color:#F00; color /*\**/:#00F\9}/*IE7,IE8識別*//*“color”和“/*\**/”之間有個空格*/
其中:OP表示Opera,SA表示Safari
————————————-
各種瀏覽器獨立支援的hack:
width:100px\0;/* 支援IE8 */

_width:100px; /* 支援IE6 */

[width:100px; /* 支援IE6,7 */

+width:100px; /* 支援IE6,7 */

*width:100px; /* 支援IE6,7 */

*width:100px!important; /* 支援IE6,7, */

*+width:100px; /* 支援IE6,7, */

*+width:100px!important;/* 支援IE6,7, */

width:100px\9; /* 支援IE6,7,8 */

width:100px!important; /* 支援IE6,7,8,FF */

w\idth:100px; /*IE5.x不支援 IE6、IE7、IE8、FF支援 */

------------------
IE條件注釋功能:

<!--[if IE]>此內容只有IE可見<![endif]–>
<!–[if IE 6.0]>此內容只有IE6.0可見<![endif]–>
<!–[if IE 7.0]>此內容只有IE7.0可見<![endif]–>

各種瀏覽器css hack

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.