CSS颜色名称+ Alpha透明度 [英] CSS color names + alpha transparency
本文介绍了CSS颜色名称+ Alpha透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在CSS中通过其名称加上alpha透明度值来定义颜色?
Is it possible to define a color in CSS by its name plus an alpha transparency value?
即:
#mytext { color: red 0.5 }
而不是诉诸于rgba之类的
rather than resorting to rgba like
#mytext { color: rgba(255,0,0,0.5) }
推荐答案
您可以通过以下方式获得所需的结果:
You can achieve the result you want this way:
#mytext{
color: red;
opacity: 0.5;
}
请注意,不透明度会影响整个元素,而不仅仅是文本,因此例如,如果#mytext元素具有背景色,那么其不透明度值也将为0.5
Note that opacity will affect the whole element, not just the text, so for example, if the #mytext element had a background color, that would also receive the opacity value of 0.5
但是,我同意Dai的观点,使用颜色名称而不是十六进制或RGB代码不是您应该过多依赖的东西。这是一个丑陋的调色板。
However, I agree with Dai, using color names instead of hex or rgb codes isn't something you should rely on too much. It's an ugly color palette to work with.
这篇关于CSS颜色名称+ Alpha透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文