且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CSS - 不透明文本在低不透明度div?

更新时间:2022-10-19 13:31:06

在背景而不是元素上设置不透明度。

  background-color:rgba 0,0,0.6); 

前面我写了关于如何以向后兼容的方式实现此功能


I have a div with 60% opacity, to show part of a background image behind the div. Because the opacity is at 60%, the text in that div appears as grey.

Is there anyway to override this level and make the text appear black?

Any advice appreciated.

Thanks.

Set the opacity on the background rather than the element.

background-color: rgba(255,0,0,0.6);

A while ago I wrote about how to achieve this in a backwards compatible way.