標籤: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樣式