Modernizr.js 关于它的一些问题

发布于 2024-12-03 23:00:46 字数 470 浏览 6 评论 0原文

我想在我的网站上使用 www.modernizr.com 项目,但遇到了一个小问题。 Modernizr.js 开头的一条评论告诉我:

Modernizr 测试哪些原生 CSS3 和 HTML5 功能可用 当前的 UA 并通过两种方式向您提供结果: 作为全局 Modernizr 对象上的属性,以及作为 html 元素。这些信息可以让您逐步增强 您的页面可以对体验进行精细的控制。

那么“作为 html 元素上的类”是什么意思? 我测试了它,只在我的文档中使用 header 元素(即 HTML5)并通过 css 操作它。 之后我用 IE6 打开它......是的,它显示正确!

所以: 我认为 header 是 html 的“元素”而不是 html 的类!?那么 modenizr.js 中的这条评论正确吗?

希望您理解我的小(或可能难以理解)问题:)

问候

I wanna use the www.modernizr.com project for my site and run into a little question.
A comment in the very beginning of the modernizr.js tells me:

Modernizr tests which native CSS3 and HTML5 features are available in
the current UA and makes the results available to you in two ways:
as properties on a global Modernizr object, and as classes on the
html element. This information allows you to progressively enhance
your pages with a granular level of control over the experience.

So what means "as classes on the html element" ?
I tested it and just use the header element (which is HTML5) in my document and manipulate it via css.
After that i opened it with IE6 and ......YEA it shows correct!

So:
I thought header is and "element" of html not a class of html!? So is this comment in the modenizr.js correct?

Hope you understand my little (or maybe hard to understand) question :)

Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

平生欢 2024-12-10 23:00:46

Modernizr 的作用是,根据您的浏览器支持的内容,向 元素添加类,让您知道(主要是通过 CSS 甚至 JS)什么似乎可以正常工作。

这意味着,如果我的浏览器不支持 javascript,如果我检查 DOM(例如使用 Chrome 的分析器),我会得到类似的信息

<html class="no-js ...">...</html>

希望这会有所帮助。

What modernizr does is, depending on what your browser support, add classes to the <html> element to let you know (mostly via CSS or even JS) what exactly seems to work properly.

That means, that if my browser doesn't support javascript, I'll get something like this if I inspect the DOM (using, for example, Chrome's profiler)

<html class="no-js ...">...</html>

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文