Max*_*lov 3 css asp.net internet-explorer conditional-statements
在IE10中调试我的ASP.NET MVC(基于Razor的)网站时,我还需要设置IE特定的css.使用IE条件注释时,在将IE10切换到IE8标准渲染模式时,以下语法有效:
<!--[if IE]><!-->
<link href="@Url.Content("~/Content/global/global.ie.css")" rel="stylesheet" type="text/css">
<!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
而这 - 不是:
<!--[if IE]>
<link href="@Url.Content("~/Content/global/global.ie.css")" rel="stylesheet" type="text/css">
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
后面的语法在大多数提供条件注释信息的站点上作为示例提供,包括MSDN上的官方页面.这两者有什么区别?先感谢您.
使用"Downlevel-revealed Conditional Comments"让它运作起来......
<![if IE]>
...statements...
<![endif]>
Run Code Online (Sandbox Code Playgroud)
<![if IE]>
<link href="@Url.Content("~/Content/global/global.ie.css")" rel="stylesheet" type="text/css">
<![endif]>
Run Code Online (Sandbox Code Playgroud)
某些验证服务将下层显示的条件注释语法标记为无效HTML.可以添加其他字符以在要显示的HTML内容之前和之后构造有效的HTML注释.
<!--[if !IE]>-->
YOUR HTML
<!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,负条件表达式阻止Internet Explorer在下层显示的条件注释块中显示HTML内容.但是,如果条件表达式的计算结果为true,则第一个注释的结束" - >"将与Internet Explorer中的HTML内容一起显示.要从Internet Explorer用户隐藏这些字符,请添加"
<!--[if !IE]><!-->
YOUR HTML
<!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
以下是一些条件注释的例子.
<!--[if IE]><p>You are using Internet Explorer.</p><![endif]-->
<![if !IE]><p>You are not using Internet Explorer.</p><![endif]>
<!--[if IE 7]><p>Welcome to Internet Explorer 7!</p><![endif]-->
<!--[if !(IE 7)]><p>You are not using version 7.</p><![endif]-->
<!--[if gte IE 7]><p>You are using IE 7 or greater.</p><![endif]-->
<!--[if (IE 5)]><p>You are using IE 5 (any version).</p><![endif]-->
<!--[if (gte IE 5.5)&(lt IE 7)]><p>You are using IE 5.5 or IE 6.</p><![endif]-->
<!--[if lt IE 5.5]><p>Please upgrade your version of Internet Explorer.</p><![endif]-->
<!--[if true]>You are using an <em>uplevel</em> browser.<![endif]-->
<![if false]>You are using a <em>downlevel</em> browser.<![endif]>
<!--[if true]><![if IE 7]><p>This nested comment is displayed in IE 7.</p><![endif]><![endif]-->
Run Code Online (Sandbox Code Playgroud)
从下载级别显示的条件注释的有效HTML中获取的内容
| 归档时间: |
|
| 查看次数: |
3073 次 |
| 最近记录: |