2012-07-19 73 views
1

這只是一個簡單的問題來澄清真的,我有一個ie7的樣式表,需要在有人通過IE7瀏覽時調用它,下面的應用程序/佈局文件中是否會調用ie7樣式表?有條件的樣式表軌跡3

<!--[if lte IE 7]> 
<%= stylesheet_link_tag "ie7", :media => "all" %> 
<![endif]--> 

回答

1

是的,那隻能爲IE7和舊版瀏覽器引入樣式表。

我覺得通過下面的代碼將一個條件類添加到html標籤通常會更好,然後在您的IE規則前面加上.lt-ieX。這使您可以將所有相關規則保存在同一個樣式表中。

<!DOCTYPE html> 
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]--> 
<!--[if IE 7]> <html class="lt-ie9 lt-ie8"> <![endif]--> 
<!--[if IE 8]> <html class="lt-ie9"> <![endif]--> 
<!--[if gt IE 8]><!--> <html> <!--<![endif]--> 

例如,

.alert { 
    color: red; 
} 
.lt-ie7 .alert { 
    color: blue; 
}