<! - [if lt IE 7]>< html class =“ie ie6” lang =" en"> <![endif] - > [英] <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->

查看:1056
本文介绍了<! - [if lt IE 7]>< html class =“ie ie6” lang =" en"> <![endif] - >的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. <! - [if lt IE 7]>< html class =ie ie6 <![endif] - > 这个和其他类似的IE代码行意味着在HTML5文档中?


  2. 必须使某些css功能兼容IE8或更低版本,上面提到的代码行或html类是否有帮助?


  3. 如果#2回答是否,那么应该使用本文中提到的条件IE样式表 - http://css-tricks.com/how-to-create-an-ie-only-stylesheet/


  4. 如果#3回答也是否,那么应该做什么使css功能在旧版本的IE中兼容。任何参考网站/演示将是一个很大的帮助!



解决方案


  1. 这是条件性语句。它们只能被IE读取。任何其他浏览器会将其读为任何正常注释,请注意<! - - > 该语句的开始和结束。 IE具有识别此注释并将注释中的内容用作常规HTML的特殊代码。特定于上面的粘贴代码,IE条件语句将一个类ie6应用于HTML标记。这样,您可以通过首先在css选择器中引用该类,为某些元素提供IE后备。例如 .ie6 #header {} 将仅应用于头部,如果存在IE6类,并且该类将仅存在于IE6中,因为条件语句。


  2. 遵循与上述相同的样式,您将使用此位代码:<! - [if IE 8] ;< html class =ie ie8lang =en><![endif] - >


  3. p>你可以使用IE样式表,如果你这样选择,任何一种方式,你将实现基本相同的结果。我个人会使用上面的方法与类的HTML标签,然后一个单独的css文件,通常称为ie.css。在这个文件中,你只有IE样式。注意,使用这种方法,样式表不需要在条件IE语句中设置。它是唯一的真正目的是一个单独的样式表是为组织目的。我也只有这样做,如果你有一个中等到大量的IE条件代码。


  4. 您也可以展开IE浏览器使用 Modernizr Selectivizr 这样的功能在一定程度上提供支持



  1. What does <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]--> this and other similar IE code lines mean in an HTML5 document?

  2. If I have to make certain css features compatible to IE8 or lower version, does above mentioned code line or html class as mentioned within it helps?

  3. If #2 answer is 'No', then should I use conditional IE stylesheet as mentioned in this article -- http://css-tricks.com/how-to-create-an-ie-only-stylesheet/

  4. If #3 answer is also 'No', then what should be done to make css features compatible in older IE versions. Any reference website / demo would be a great help!

解决方案

  1. This is a conditional IE statement. They are only read by IE. Any other browser will read them as any normal comment, note the <!-- and --> at the beginning and end of the statement respectively. IE has special code that recognizes this comment and uses whats inside the comment as regular HTML. In specific to your pasted code above, the IE conditional statement is applying a class of ie6 to the HTML tag. In this way you can provide IE only fall backs for certain elements by first referencing that class in your css selector. For example .ie6 #header {} will only apply to the header if the IE6 class is present, and that class will only be present in IE6 because of the conditional statement.

  2. Following the same style as above, you would use this bit of code: <!-- [if IE 8]><html class="ie ie8" lang="en"><![endif]-->

  3. You could use an IE stylesheet if you so choose, either way you would achieve essentially the same result. I personally would use the above method with the class on the HTML tag, and then a separate css file that is loaded normally called ie.css. Inside this file, you would have nothing but IE styles. Note that with this method the stylesheet does not need to be setup in a conditional IE statement. It's only real purpose in being a separated stylesheet is for organizational purposes. I would also only do this if you have a moderate to large amount of IE conditional code. If you have minimal IE fall-back code, simply include the code next to your the code it is fixing inside your master stylesheet.

  4. You can also expand IE support to a certain extent using things like Modernizr and Selectivizr

这篇关于&lt;! - [if lt IE 7]&gt;&lt; html class =“ie ie6” lang =&quot; en&quot;&gt; &lt;![endif] - &gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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