如何使用CSS反转颜色? [英] How can I invert color using CSS?
本文介绍了如何使用CSS反转颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HTML
<div>
<p>inverted color</p>
</div>
CSS
div {
background-color: #f00;
}
p {
color: /* how to use inverted color here in relation with div background ? */
}
有什么方法可以用CSS反转p
颜色?
Is there any way to invert the p
color with CSS?
有color: transparent;
为什么连CSS3也没有color: invert;
?
There is color: transparent;
why not color: invert;
even in CSS3?
推荐答案
为段落添加相同颜色的背景,然后使用CSS反转:
Add the same color of the background to the paragraph and then invert with CSS:
div {
background-color: #f00;
}
p {
color: #f00;
-webkit-filter: invert(100%);
filter: invert(100%);
}
<div>
<p>inverted color</p>
</div>
这篇关于如何使用CSS反转颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文