I have an element with text in it. Whenever I decrease the opacity, then I decrease the opacity of the WHOLE body. Is there any way I can just make the background-image
darker, and not everything else?
background-image:url('http://fc02.deviantart.net/fs71/i/2011/274/6/f/ocean__sky__stars__and_you_by_muddymelly-d4bg1ub.png');
Just to add to what's already here, use the following:
...for cross-browser support of a 70% linear-gradient overlay. To brighten the image, you can change all those
0,0,0
's into255,255,255
's. If 70% is a bit much, go ahead and change the.7
. And, for future reference check out this: http://www.colorzilla.com/gradient-editor/It might be possible to do this with
box-shadow
however, I can't get it to actually apply to an image. Only on solid color backgrounds
For me the filter/gradient approach didn't work (perhaps due to the existing CSS) so I have used
:before
pseudo styling trick instead:Setting
background-blend-mode
todarken
would be the most direct and shortest way to achieve the purpose however you must set abackground-color
first for the blend mode to work.This is also the best way if you need to manipulate the values in javascript later on.
You can use a container for your background, placed as absolute and negative z-index : http://jsfiddle.net/2YW7g/
HTML
CSS
Use an :after psuedo-element:
Check out my pen >
http://codepen.io/craigocurtis/pen/KzXYad