How to target IE9 with new HTML5 Boilerplate?

帅比萌擦擦* 提交于 2020-01-10 11:52:05

问题


I am trying to target a class for IE. However, since the boilerplate template has changed this no longer works..

.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]-->

回答1:


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:

<!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.




回答2:


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:

.myclass {}


来源:https://stackoverflow.com/questions/9233468/how-to-target-ie9-with-new-html5-boilerplate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!