关于 CSS3/@Import 和验证 CSS2.1 的几个问题
这个周末,我为一个虚构的网站制作了一个模板。我经常这样做,尝试用最少的标记和非常简洁的 CSS 构建一个编码非常干净的网站模板。
我希望我的网站在将其交给客户之前能够完美验证。
我有两个问题(我想知道其他人如何制作一个完全有效的网站)使用: http://validator.w3.org /check
我使用了一些 CSS3 属性(转换、盒子阴影、边框半径等),这使得网站无法通过验证,因为验证器会根据 CSS 2.1 规范进行检查(我猜)。你们是否使用任何方法仍然通过 CSS 中的这些属性传递验证器?您是否将它们分开并用条件注释包裹起来?
第二个是 @import CSS 方法。在我的标题中,我有一个名为 main.css 的样式表。在这个样式表中,我有这样的内容:
/*site structure*/
/*@import url("grid_system_960.css");*/
/*default style rules
@import url("layout.css"); */
/*navigation.css
@import url("navigation.css");*/
我只是这样做以保持CSS模块化和干净,但@import也未能通过验证器。
有人对我可以采取的任何建议来改进我的结构/方法吗?
This weekend, I made a template for a ficticious website. I do this every so often to try to build a very cleanly coded website template with minimal markup and very concise CSS.
I want my sites to validate perfectly before I hand them over to the client.
I have two problems ( I was wondering how others make a completely valid website ) using : http://validator.w3.org/check
I use some CSS3 properties (transitions, box-shadows, border-radius, etc) which make the site fail the validation since the validator checks against the CSS 2.1 spec (I guess). Are there any methods you guys use to still pass the validator with these properties in the CSS? Do you seperate them and wrap them in conditional comments?
The second is the @import CSS method. In my header, I have one stylesheet called main.css. In this stylesheet, I have something like this:
/*site structure*/
/*@import url("grid_system_960.css");*/
/*default style rules
@import url("layout.css"); */
/*navigation.css
@import url("navigation.css");*/
I simply do it like this to keep the CSS modular and clean, but the @import also failed the validator.
Has anybody got any suggestions that I could take to improve my structure/method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
停止。验证是一种工具,而不是竞争。如果您了解代码失败的原因以及偏离规范的后果,那么这不是问题。
不要在生产代码中使用它。它会增加 HTTP 请求的数量并降低网站速度。在发布之前合并并缩小 CSS。
那么你使用它是错误的(可能是因为未能将其作为样式表中的第一件事)。 “在 CSS 2.1 中,任何 @import 规则必须先于所有规则其他规则(@charset 规则除外,如果存在)。”
Stop. Validation is a tool, not a competition. If you understand why the code fails and the consequences of how you deviate from the specification, then it isn't a problem.
Don't use this in production code. It increases the number of HTTP requests and slows the site down. Combine and minify CSS before publication.
Then you are using it wrong (probably by failing to make it the first thing in the stylesheet). "In CSS 2.1, any @import rules must precede all other rules (except the @charset rule, if present)."