简体   繁体   English

CSS 验证器错误 = 值错误:背景 100% 不是颜色停止值)

[英]CSS Validator error = Value Error : background 100% is not a color-stop value )

I am pretty new to programming and I imported a code snippet to my CSS to get a hovering effect over links.我对编程很陌生,我将代码片段导入到我的 CSS 中,以获得悬停在链接上的效果。 When I am pushing the code through W3C CSS Validator I get a single error which is from this imported code.当我通过 W3C CSS Validator 推送代码时,我收到一个来自此导入代码的错误。

I do not understand what I can do to remove the error, because the hovering effect works perfectly.我不明白我能做些什么来消除错误,因为悬停效果完美无缺。

Can anyone help me?谁能帮我? Would be greatly appreciated!将不胜感激!

The error:错误:

Value Error : background 100% is not a color-stop value )值错误:背景 100% 不是颜色停止值)

Code:代码:

 :root { --mainColor: #ffc7c7; } .details-schedule { align-items: center; display: flex; font-family: 'Libre Franklin', sans-serif; font-size: 16px; justify-content: center; } .details-schedule a { background: linear-gradient( to bottom, var(--mainColor) 0%, var(--mainColor) 100% ); background-position: 0 100%; background-repeat: repeat-x; background-size: 4px 4px; color: #000; text-decoration: none; transition: background-size .6s; } .details-schedule a:hover { background-size: 4px 50px; }

It seems that this is a quirk, well a bug, of the W3C CSS validator.这似乎是 W3C CSS 验证器的一个怪癖,也是一个错误。 Any value, eg 2%, produces the same error.任何值,例如 2%,都会产生相同的误差。

If you replace the second var(—mainColor) with an actual color, like blue, or with the hex value of —mainColor then the validator is happy so if passing validation is important to your project then perhaps do that for now.如果您将第二个 var(-mainColor) 替换为实际颜色(如蓝色)或十六进制值 —mainColor ,则验证器很高兴,因此如果通过验证对您的项目很重要,那么现在可能会这样做。

Incidentally, the validator can't cope with a color like rgba(0,0,0,1) either so it seems to be it has a problem parsing the brackets.顺便说一句,验证器也无法处理像 rgba(0,0,0,1) 这样的颜色,所以它似乎在解析括号时有问题。

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

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