Html 如何使用新的 HTML5 Boilerplate 定位 IE9?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9233468/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to target IE9 with new HTML5 Boilerplate?
提问by user992731
I am trying to target a class for IE. However, since the boilerplate template has changed this no longer works..
我正在尝试为 IE 定位一个类。但是,由于样板模板已更改,因此不再有效。
.myclass {
//do something
}
.ie7 .myclass {
///do something
}
This is what's in the new header of the boilerplate template.
这是样板模板的新标题中的内容。
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
回答by Divya Manian
We do not recommend you target IE9 as it has all the marking of a modern browser, which is why we do not have IE9 specific conditional class. If you still would like to, you can use:
我们不建议您以 IE9 为目标,因为它具有现代浏览器的所有标记,这就是我们没有 IE9 特定条件类的原因。如果您仍然愿意,可以使用:
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if IE 9]> <html class="no-js lt-ie10" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
Note that IE10 will not recognize conditional comments.
请注意,IE10 不会识别条件注释。
回答by PeeHaa
Yak Boilerplate! Anyway:
牦牛锅!反正:
.lt-ie9.lt-ie8 .myclass {}
should do what you want.
应该做你想做的。
EDIT
编辑
Sorry misread your question since you put IE7 in example. If you want to IE9 you can just do:
抱歉误读了您的问题,因为您以 IE7 为例。如果你想要 IE9,你可以这样做:
.myclass {}