10

我看到很多网站都有 ie6、ie7、ie8 的特定代码。

<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->

我似乎 html 有这样的特定类

<html class=" js no-flexbox flexbox-legacy canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths">

任何人都只是告诉这个代码有什么用

4

3 回答 3

10

这是对 Moderniz 的说明。如果您的浏览器中启用了 JavaScript,Modernizr 会更改no-jsjs类,因此您可以为启用 JavaScript 的浏览器和禁用 JavaScript 的浏览器定义 CSS 样式

于 2013-08-19T08:26:29.870 回答
7

它放在那里,如果有Javascript支持,那么您可以使用 JS 删除no-js该类。

no-js如果您通常需要 JS 来使您的网站正常运行,则可以使用该类来为您的网页设置 CSS 样式。如果您想提供足够的 HTML 和足够的表单以使页面在没有 JS 的情况下工作,那么这提供了一种降级但功能强大的格式,但随后隐藏 ghetto-version 并用闪亮和花哨的东西替换它。

于 2012-09-28T07:03:48.923 回答
3

<!--[if IE]><![endif]-->是微软的有条件评论

因此对于 IE 版本 < 7 ( [if lt IE 7]),<html lang="en" class="no-js ie6">使用;

对于 IE 版本 7 ( [if IE 7]),<html lang="en" class="no-js ie7">使用;

等等。

最后,对于 IE 版本 > 9( [if gt IE 9]),<html lang="en" class="no-js">使用。

而且由于是微软特有的注释,所有非IE浏览器都会把它当作普通注释,所以只使用<html lang="en" class="no-js">(唯一未注释的部分)。

于 2012-09-28T07:03:58.460 回答