使用两个条件CSS if语句既不使用样式表 [英] Using two conditional css if statements uses neither style sheet

查看:133
本文介绍了使用两个条件CSS if语句既不使用样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的智慧结束在这里。试图实现两个不同的样式表,一个用于IE,另一个用于非IE。在我见过的每一个例子中,这都是你应该这样做的方式。任何人都可以在这发现任何错误?看起来应该很简单。

 <! -  [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 ] - GT;


解决方案

对于!IE 条件注释,正确的格式为<! - [IF!IE]> - > ...<! - <![endif] - > ,因为非IE浏览器对条件注释没有特殊待遇。

 <! -  [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 ] - GT;

另见: http://www.quirksmode.org/css/condcom.html

PS。不再支持IE10中的条件注释。


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

解决方案

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.

这篇关于使用两个条件CSS if语句既不使用样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆