如何在容器div而不是儿童文本上设置不透明度? [英] How to set opacity on container div and not on children text?
问题描述
我有一个DIV与CSS样式规则 opacity:0.4;
。
I have a DIV with the CSS style rule opacity: 0.4;
.
a a
标签,文本也有不透明度。
Inside the div there is a a
tag and the text also has an opacity.
如何声明文本: opacity:1
或任何好主意....
你可以在以下链接中看到它:http://yagen.org/
How can I declare for the text: opacity :1
or any good idea....
You can see it in the following link:http://yagen.org/
图库在上面的页面。
推荐答案
如果你设置一个元素的不透明度,不透明度也为其所有的孩子设置。
If you set the opacity of an element, the opacity is set for all of its children as well. If you want opaque text on a transparent background, take a look at RGBa.
结果看起来像这样:
.mycontainer {
background: rgb(60, 60, 60);
background: rgba(60, 60, 60, 0.4);
}
.mycontainer a {
color: #fff;
}
第一个后台声明用作后备
The first background declaration serves as a fallback in case a browser doesn't support RGBa color - it will simply be a solid color instead.
这里是RGBa颜色的一个很好的参考: http://css-tricks.com/2151-rgba-browser-support/
Here's a great reference for RGBa color: http://css-tricks.com/2151-rgba-browser-support/
这篇关于如何在容器div而不是儿童文本上设置不透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!