CSS3 box-shadow属性不验证? [英] CSS3 box-shadow property doesn't validate?
问题描述
当我通过W3C的验证器运行我的CSS,任何时候使用 box-shadow
属性,我得到这样的错误:
When I run my CSS through the W3C's validator, any time I use the box-shadow
property, I get an error like this:
0不是框阴影值:0 0 10px#000
0 is not a box-shadow value : 0 0 10px #000
它似乎停止在任何第一个值,因为更改值的顺序将更改错误匹配:
It appears to stop at whatever the first value is, since changing the order of the values will change the error to match:
000不是框阴影值:#000 0 0 10px
#000 is not a box-shadow value : #000 0 0 10px
我使用设置为CSS3的配置文件进行验证,因此不是我忘记从CSS2(其中 box-shadow
属性不存在)更改默认配置文件设置的情况。
I'm validating with the profile set to CSS3, so it's not a case of me forgetting to change the default profile setting from CSS2 (where the box-shadow
property doesn't exist).
为什么它不认为我使用的任何值是正确的?在支持非前缀 box-shadow
属性的Firefox和任何其他浏览器中,阴影将呈现完美。
Why doesn't it think any of the values I'm using are correct? The shadow will render perfectly fine in Firefox and any other browser that supports the non-prefixed box-shadow
property.
推荐答案
这是一个已知的验证程序错误。显然,他们忘记了无单位的值是允许的(尤其是无单位的零值)。你的CSS没有什么问题;您使用的值是正确的。
It's a known validator bug. Apparently they forgot that unitless values are permitted (especially unitless zero values). There's nothing wrong with your CSS; the values you're using are correct.
如果你很挑剔,你不能忍受错误,玷污你否则会成功验证,您可以简单地将单位添加到零值:
If you're picky and you can't put up with the bug tarnishing your otherwise would-have-been successful validation, you can simply add units to your zero values:
box-shadow: 0px 0px 10px #000;
但是每当我遇到这样的情况时,我通常不会打扰,知道这是一个无害的
But whenever I run into situations like this, I normally don't bother, knowing that it's a harmless validator bug and not something wrong with my CSS.
请注意,在此更新过程中,错误已修复,因为 2012年8月30日。
Note that as of this update the bug has been fixed since August 30, 2012.
这篇关于CSS3 box-shadow属性不验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!