The opacity
property is not suited for this kind of problem, because it's automatically inherited by children elements. If a table has 0.3 opacity, all its cells (and their text) becomes equally transparent (details here). To get around this, you'd have to reset the opacity of these children back to 1, but that's a lot more CSS to add.
Instead, let me suggest a couple easy alternatives:
1. Use a semi-transparent PNG image
You can make one at 1x1px.com and download it to your site.
Then reference it using background-image
, for example:
background-image:url(path-to-your-image.png);
height:145px;
color:#ffffff;
2. Use CSS3's rgba ability
The rgba
ability gives us an easier method, but it is not supported in IE8. If you want to support this browser, use the PNG image technique instead.
The CSS for this technique is:
background-color:rgba(255,255,255,0.3);
height:145px;
color:#ffffff;
See it in action here: http://jsfiddle.net/49d7rxm9/
Answers derived from this post: https://stackoverflow.com/a/806189/2391142