CSS Background Opacity
This question already has an answer here:
To use opacity on the background only, you don't use opacity
because this will also affect all of the children of the container you apply it to.
To use opacity only on the background color, you'll have to use color definition in rgba()
format. For example if you want white background-color and opacity of 0.5, this would be the rgba:
rgba(255,255,255,0.5);
In your css example, put
background-color: rgba(225,222,222,0.6);
and remove the
opacity: 0.6;
You should use background: rgba(0-255,0-255,0-255,0-1)
.
Opacity affects all child elements if you apply it to the parent.
Try like this:
.wrapper{
background:rgba(0,0,0,.5) url(...);
}
Dont use opacity
for the parent div
, instead use rgba()
to make transparent Background, this dont affect all the child elements.
上一篇: 我怎样才能让任何颜色的字体可读?
下一篇: CSS背景不透明