问题
This is what is happening when you visit my site in IE9 -
This is the code that is causing this:
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<link rel="stylesheet" href="stylesheets/ie.css" media="screen" />
<![endif]-->
<!--[if !IE]-->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!--[endif]-->
<!--[if !IE]-->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!--[endif]-->
Thoughts?
回答1:
EDIT: fixed according to the commenters, thanks. See also the other answers.
Corrected code (second part):
<!--[if !IE]> -->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!-- <![endif]-->
<!--[if !IE]> -->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!-- <![endif]-->
回答2:
Actually, the "dashes" are correct, but first you must close the conditionals, like so:
<!--[if !IE]> -->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!-- <![endif]-->
<!--[if !IE]> -->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!-- <![endif]-->
Not adding the "dashes" will cause no browser to pay attention to these conditionals. Non-IE browsers do not read comments, so the code must be outside the comment for the !IE
condition.
回答3:
<!--<![if (IE X)|(IE Y)]--><link href="../css/style.css" rel="stylesheet" type="text/css" media="all" /><!--<![endif]-->
Above conditional comment will work properly For Hiding Comment line you must have to add <!--<!
in this format
回答4:
You're closing your comments prematurely. Your conditional comments should open like:
<!--[cond]>
and end like:
<![end]-->
You did the first one right, but because your opening tags end with -->
, that closes the comment right there, so the link tag, which is supposed to be part of the comment, isn't, and is interpreted as regular HTML.
Hope that helps!
来源:https://stackoverflow.com/questions/9675750/if-ie-comments-showing-up-in-ie9