MrWeb
MrWeb

Reputation: 91

Div background opacity?

I just want add a dark overlay for my div background. I add black as a background color and set opacity to 0.5 But the problem is that child element divs also apply that opacity. See my screenshot. I just want to add that overlay for my parent div background only. Is there any specific way of doing this?

enter image description here

Upvotes: 1

Views: 976

Answers (1)

BenM
BenM

Reputation: 53208

You can use a semi-transparent PNG file as the background image, or just use the RGBA colour system:

background: rgba(0,0,0,.5);

jsFiddle Demo

rgba() is supported in all modern browser.

Upvotes: 2

Related Questions