Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

countering a div opacity?

Tags:

css

If I have a div that acts like a box, and I make it real sexy with 10% opacity. How do I counter it since everything in the div also gets the opacity. Lets say i have a box(div) with a 1px border and text, putting opacity on it will make it look bad and i only want opacity on the background.

like image 499
Jason94 Avatar asked May 11 '10 13:05

Jason94


1 Answers

This is how you can apply opacity on background colors only, and not to the whole element and his children:

background: rgba(0,0,0, 0.5) //gives you a black background with 50% opacity

you can test it out here: http://jsfiddle.net/ypaTH/

there was a similar question here: How to give cross browser transparency to element's background only? (with IE version)

like image 130
meo Avatar answered Sep 22 '22 03:09

meo