Is there a way to add transparency to a background-image using CSS3?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are using an image tag to set the image, it can be easily changed using the CSS3 property “opacity”.
It is written like this:
the value for opacity must be between 0 and 1. 0 being invisible and 1 being opaque.
If you are applying the background image by using the CSS “background-image” property then you can still use the opacity to change the background image but it must be done in a different way.
This is because the opacity value changes the opacity on the entire element when you only want the opacity changed on the background image.
There is an easy way to work around this: just overlay the content over the image and wrap them in a common parent and apply the opacity change to only the background part:
HTML
CSS