How do I make a semi transparent background?
I need to make a white background 50% transparent without affecting anything else. How do I do it?
Solution 1:
Use rgba()
:
.transparent {
background-color: rgba(255,255,255,0.5);
}
This will give you 50% opacity while the content of the box will continue to have 100% opacity.
If you use opacity:0.5
, the content will be faded as well as the background. Hence do not use it.
Solution 2:
This works, but all the children of the element with this class will also become transparent, without any way of preventing that.
.css-class-name {
opacity:0.8;
}