为什么 YUI Reset CSS 没有通过验证?

发布于 2024-08-03 04:39:06 字数 469 浏览 3 评论 0原文

我尝试使用 W3C CSS 验证器来验证我网站的 CSS。不幸的是,YUI 框架中的 reset-min.css 在字符串“ {*font-size:100%; ”上产生了解析错误。

验证器结果。

经过进一步调查,我注意到 Firefox 错误控制台上出现以下错误:

警告:符合预期声明,但发现“*”。跳到下一个声明。

我找不到任何关于“*”含义的解释,也找不到这个流行的重置 CSS 中问题的参考资料。

我缺少什么?

I tried to validate my site's CSS using the W3C CSS Validator. Unfortunately, reset-min.css from YUI framework produced parse error on the string " {*font-size:100%; ".

The validator results.

On further investigation I noticed the following error on Firefox's error console:

Warning: Expected declaration but found '*'. Skipped to next declaration.

I couldn't find any explanation for the meaning of the '*', nor references for a problem in this popular reset CSS.

What am I missing?

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

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

发布评论

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

评论(2

魔法唧唧 2024-08-10 04:39:06

这是针对 IE7 及更低版本的破解。 IE7 及更低版本将跳过星号并继续正常解析 CSS。其他浏览器将忽略整个规则。

例如,由于 CSS 将使用规则的最后声明版本,因此执行以下操作将导致 IE7 及更低版本使用 113% 的 font-size,而其他浏览器则使用 font -段落大小为 100%。

p { font-size: 100%; *font-size: 113%; }

webdevout.net 上有更多信息。

就我个人而言,我认为使用此类 hack 来解决 IE 的问题是可以接受的。显然,雅虎!感觉是一样的。

This is a hack for IE7 and lower. IE7 and lower will skip the asterisk and continue to parse the CSS as normal. Other browsers will just ignore the entire rule.

As an example, since CSS will use the last declared version of a rule, doing the following will cause IE7 and below to use a font-size of 113%, while other browsers use a font-size of 100% for paragraphs.

p { font-size: 100%; *font-size: 113%; }

There is a little more information at webdevout.net.

Personally, I think that it is acceptable to use such hacks for the purposes of working around the brokenness of IE. Apparently, Yahoo! feels the same way.

一瞬间的火花 2024-08-10 04:39:06

这可能是 IE 兼容性问题。

有许多 CSS 语法错误,一些浏览器(尤其是 IE 6)会忽略,而另一些则不会。某些 CSS 文件将使用这些错误来制定一个规则,一个浏览器可以看到,而另一个浏览器则看不到。

编辑:有关完整列表,请参阅此处。在您的特定情况下,只有 IE 7 或更低版本才能看到该规则。

It's probably an IE compatibility hack.

There are many CSS syntax errors that some browsers (notably IE 6) will ignore and others won't. Some CSS files will use the errors to make a rule that one browser will see and another browser won't.

EDIT: For a full list, see here. In your particular case, that rule will be seen only by IE 7 or lower.

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