CSS “-webkit-text-fill-color”和“color”的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9287552/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between "-webkit-text-fill-color" and "color"?
提问by android.nick
I'm trying to understand the difference between -webkit-text-fill-color
and just simply color
? Is there any functional difference? So far as I can tell, they're exactly the same.. Is there something you could do with one but not the other?
我想明白之间的差别-webkit-text-fill-color
,只是简单地color
?有什么功能上的区别吗?据我所知,它们完全相同......你可以用一个而不是另一个来做些什么吗?
回答by Andrew Marshall
From the WebKit blog:
来自WebKit 博客:
text-fill-color
– This property allows you to specify a fill color for text. If it is not set, then thecolor
property will be used to do the fill.
text-fill-color
– 此属性允许您指定文本的填充颜色。如果未设置,则该color
属性将用于进行填充。
So yes, they are the same, but -webkit-text-fill-color
will take precedence over color
if the two have different values.
所以是的,它们是相同的,但如果两者具有不同的值-webkit-text-fill-color
,color
则优先。
I think the rationale for this is that you can choose a different color if you want when using -webkit-text-stroke
, but it will gracefully fall back to color
if -webkit-text-stroke
isn't available (and thus -webkit-text-fill-color
isn't either). There may be cases where you would otherwise end up with unreadable text.
我认为这样做的理由是,您可以在使用 时根据需要选择不同的颜色-webkit-text-stroke
,但color
如果-webkit-text-stroke
不可用,它将优雅地回退(因此-webkit-text-fill-color
也不是)。在某些情况下,您可能会以不可读的文本结束。
回答by Micah Winkelspecht
-webkit-text-fill-color
can be set to transparent
which allows you to do some really interesting things on text, like setting a horizontal gradient. Check out this rainbow text example: http://jsfiddle.net/DoubleYo/qGfzm/
-webkit-text-fill-color
可以设置为transparent
允许你对文本做一些非常有趣的事情,比如设置水平渐变。查看这个彩虹文本示例:http: //jsfiddle.net/DoubleYo/qGfzm/