CSS瀏覽器安全色----IE的定製CSS樣式

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   os   使用   ar   for   

#條件聲明(在另一篇文章中已有詳細講解說明了),也是解決IE相容性最常用的方法

<!--[if IE 8]><style type="text/css">/* css for IE 8 */</style><![endif]--><!--[if lt IE 8]><link href="ie7.css" rel="stylesheet" type="text/css" /><![endif]-->

#對於不同版本的IE相應的CSS規則,也是一種可選擇的方式。

IE8及或下版本:添加9(\9)屬性後

IE7或以下版本:添加屬性前添加*

IE6:屬性前添加_

.box {background: gray; /* standard */background: pink\9; /* IE 8 and below */*background: green; /* IE 7 and below */_background: blue; /* IE 6 */}

#條件聲明裡面,添加<html>的Class:

這種方法是Paul Irish發明的,使用相應的IE class作為父類例如:

  .ie6 .box

<!--[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]-->

 

<style type="text/css">body {background: #efefef;font: 1em/1.5em Arial, Helvetica, sans-serif;color: #666;width: 80%;margin: 20px auto;}a {color: #F60;}.box {color: #fff;padding: 5px 20px;background: gray; }.ie8 .box {background: pink;}.ie7 .box {background: green;}.ie6 .box {background: blue;}</style>

 

  

 

#下面是顯示結果不同IE下的一個例子:

 VIEW DEMOIE Specific

 

CSS瀏覽器安全色----IE的定製CSS樣式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.