如何减少渐变错误?

时间:2011-11-20 23:02:07

标签: css validation gradient

我刚尝试验证一个大的css文件,最终遇到89个错误!为了节省时间,我尝试在color zilla使用跨浏览器渐变生成工具。这些生成的渐变最终导致了大约90%的错误:

background: rgb(56,115,160); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(56,115,160,1) 0%, rgba(55,107,147,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(56,115,160,1)), color-stop(100%,rgba(55,107,147,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(56,115,160,1) 0%,rgba(55,107,147,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(56,115,160,1) 0%,rgba(55,107,147,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(56,115,160,1) 0%,rgba(55,107,147,1) 100%); /* IE10+ */
background: linear-gradient(top,  rgba(56,115,160,1) 0%,rgba(55,107,147,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3873a0', endColorstr='#376b93',GradientType=0 ); /* IE6-9 */

我的错误是:

391     #nav    Value Error : background Too many values or values are not recognized : -moz-linear-gradient(top,rgba(21,60,91,1 ) 0%,rgba(43,63,81,1 ) 100% )

392     #nav    Value Error : background Too many values or values are not recognized : -webkit-gradient(linear,left top,left bottom,color-stop(0%,rgba(21,60,91,1 ) ),color-stop(100%,rgba(43,63,81,1 ) ) )

393     #nav    Value Error : background Too many values or values are not recognized : -webkit-linear-gradient(top,rgba(21,60,91,1 ) 0%,rgba(43,63,81,1 ) 100% )

394     #nav    Value Error : background Too many values or values are not recognized : -o-linear-gradient(top,rgba(21,60,91,1 ) 0%,rgba(43,63,81,1 ) 100% )

395     #nav    Value Error : background Too many values or values are not recognized : -ms-linear-gradient(top,rgba(21,60,91,1 ) 0%,rgba(43,63,81,1 ) 100% )

396     #nav    Value Error : background Too many values or values are not recognized : linear-gradient(top,rgba(21,60,91,1 ) 0%,rgba(43,63,81,1 ) 100% )

397     #nav    attempt to find a semi-colon before the property name. add it

397     #nav    Property progid doesn't exist : DXImageTransform

397     #nav    Parse Error DXImageTransform.Microsoft.gradient( startColorstr='#153c5b', endColorstr='#2b3f51',GradientType=0 ); 

所有浏览器的渐变效果都很好。我应该关注这些错误吗? 如果是这样,我最好的选择是什么?

2 个答案:

答案 0 :(得分:3)

你不应该担心这些错误。因为它们是供应商特定的,所以它们不会验证。我建议您下次验证时不要检查特定于供应商的前缀。

答案 1 :(得分:2)

不要指望您的CSS能够使用W3C验证器完全验证。见http://na.isobar.com/standards/#_css_validation