October 22 2015

CSS set opacity background color only not text and image

Tagged Under :

To set the opacity level for a <div> element as the below example:
div {
    opacity: 0.5;
But the following example will let the content inside the <div> become transparent as well.

Instead of using “opacity” to set transparent background-color. You can try using “rgba” function as below.
background-color: rgba(255, 0, 0, 0.5);
Now, only the background is transparent.

Make a Comment

You must be logged in to post a comment.