问题
At my wit's end here. Trying to implement two different style sheets, one for IE and one for when it's not IE. In every example I've ever seen this is exactly the way you're supposed to do this. Can anyone spot any mistakes in this? Seems like it should be simple enough.
<!--[if !IE]><link rel='stylesheet' type='text/css' href='/login/css/correctlogin.css'/><![endif]-->
<!--[if IE]><link rel='stylesheet' type='text/css' href='/login/css/ielogin.css'/><![endif]-->
回答1:
For the !IE
conditional comment, the correct format is <!--[IF !IE]>--> ... <!-- <![endif]-->
, because non-IE browsers do not have a special treatment for the conditional comments.
<!--[if !IE]> --><link rel='stylesheet' type='text/css' href='/login/css/correctlogin.css'/><!-- <![endif]-->
<!--[if IE]><link rel='stylesheet' type='text/css' href='/login/css/ielogin.css'/><![endif]-->
See also: http://www.quirksmode.org/css/condcom.html
PS. Conditional comments are not supported in IE10 any more.
回答2:
The if not IE statement is redundant. All you need is an if IE statement.
<link rel='stylesheet' type='text/css' href='/login/css/correctlogin.css'/>
<!--[if IE]>
<link rel='stylesheet' type='text/css' href='/login/css/ielogin.css'/>
<![endif]-->
This tells every browser to use correctlogin.css
and if the browser is IE, THEN also use ielogin.css
来源:https://stackoverflow.com/questions/9709715/using-two-conditional-css-if-statements-uses-neither-style-sheet