I think the following will work.
Wrap the image in a container:
<div class="img-overlay"> <img src="http://placekitten.com/200/200"> </div>
apply the following CSS:
.img-overlay { border: 1px solid blue; float: left; position: relative; } .img-overlay:before { content: ''; position: absolute; top: 0; bottom: 0; left: 0; right: 0; background-color: white; filter: alpha(opacity=40); opacity: 0.4; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=40)"; } img { display: block; }
See the demo at http://jsfiddle.net/audetwebdesign/DkRJs/
The idea is to use absolute positioning to position the element over the image, and then apply the opacity property.
If older browsers do not support the pseudo-element, you will need to directly place it in the HTML code.
Note: I just re-read the original question and realized that I solved the wrong problem. Sorry for the inconvenience.
IE8 problem
I tested this in IE8 and realized that you need a filter property to make it fully backward compatible.
Marc audet
source share