这只是一个需要澄清的快速问题,我有一个 ie7 样式表,当有人通过 IE7 浏览时需要调用它,我的应用程序/布局文件中的以下内容会调用 ie7 样式表吗?
<!--[if lte IE 7]>
<%= stylesheet_link_tag "ie7", :media => "all" %>
<![endif]-->
这只是一个需要澄清的快速问题,我有一个 ie7 样式表,当有人通过 IE7 浏览时需要调用它,我的应用程序/布局文件中的以下内容会调用 ie7 样式表吗?
<!--[if lte IE 7]>
<%= stylesheet_link_tag "ie7", :media => "all" %>
<![endif]-->
是的,那应该只为 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;
}