The problem with
opacity is that it will also affect the content, when often you do not want this to happen.
If you just want your element to be transparent, it's really as easy as :
But if you want it to be in colors, you can use:
background-color: rgba(255, 0, 0, 0.4);
Or define a background image (
1px) saved with the right
(To do so, use
Paint.Net or any other image software that allows you to do that.
Just create a new image, delete the background and put a semi-transparent color in it, then save it in png.)
As said by René, the best thing to do would be to mix both, with the
rgba first and the
1px image as a fallback if the browser doesn't support alpha :
background: url('img/red_transparent_background.png'); background: rgba(255, 0, 0, 0.4);
See also : http://www.w3schools.com/cssref/css_colors_legal.asp.
Demo : My JSFiddle
~ Answered on 2012-08-04 08:59:48