简体   繁体   English

关于CSS3 / @ Import和验证CSS2.1的几个问题

[英]A Few Questions About CSS3/@Import and Validation CSS2.1

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. 我经常这样做,以尝试建立一个标记最少,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 我有两个问题(我想知道其他人如何制作一个完全有效的网站): 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). 我使用一些CSS3属性(过渡,框阴影,边界半径等),由于验证程序对照CSS 2.1规范进行了检查,因此使网站无法通过验证(我想)。 Are there any methods you guys use to still pass the validator with these properties in the CSS? 你们有什么方法仍然可以在CSS中使用带有这些属性的验证器? Do you seperate them and wrap them in conditional comments? 您是否将它们分开并用条件注释将它们包装起来?

The second is the @import CSS method. 第二个是@import CSS方法。 In my header, I have one stylesheet called main.css. 在标题中,我有一个样式表称为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. 我只是这样做,以保持CSS模块化和整洁,但是@import也使验证程序失败。

Has anybody got any suggestions that I could take to improve my structure/method? 有没有人建议我改善自己的结构/方法?

I want my sites to validate perfectly before I hand them over to the client.. 我希望我的网站能够完美地进行验证,然后再将其移交给客户。

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. 如果您了解代码失败的原因以及偏离规范的后果,那么这不是问题。

as the validator checks using CSS 2.1 spec 验证者使用CSS 2.1规范进行检查

验证器将使用您指定的任何配置文件

The second is the @import CSS method. 第二个是@import CSS方法。

Don't use this in production code. 不要在生产代码中使用它。 It increases the number of HTTP requests and slows the site down. 它增加了HTTP请求的数量,并降低了站点速度。 Combine and minify CSS before publication. 在发布之前合并并缩小CSS。

@import also failed the validator @import也使验证程序失败

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)." “在CSS 2.1中,任何@import规则都必须位于所有其他规则之前(@charset规则(如果存在)除外)。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM