如何使用CSS为文本或图像提供透明背景?
问题: Is it possible, using CSS only, to make the background of an element semi-transparent but have the content (text & images) of the element opaque? 仅使用CSS,是否可以使元素的 background 半透明,但元素的内容(文本和图像)不透明? I'd like to accomplish this without having the text and the background as two separate elements. 我想在没有文本和背景作为两个独立元素的情况下完成此操作。 When trying: 尝试时: p { position: absolute; background-color: green; filter: alpha(opacity=60); opacity: 0.6; } span { color: white; filter: alpha(opacity=100); opacity: 1; } <p> <span>Hello world</span> </p> It looks like child elements are subjected to the opacity of their