I want to change the brightness of a DIV's background, without affected the other contents in a div.
When I apply a hover brightness filter on the div, other elements in it are also affected. Which I do not want.
The other solution I have is simply replacing the background of the div with a photo edited one. But that asks for double the storage, which I do not like.
Is there a way to change just the brightness of the background-image?
<div id="replace">
<div id="transparent">
<span id="text">Random unaffected text</span>
</div>
</div>
<div id="brightnessfilter">
<div id="transparent">
<span id="text">Random AFFECTED text (it glows)</span>
</div>
</div>
#replace {
width:700px;
height:465px;
background-image:url('http://i42.tinypic.com/351dff5.jpg');
}
#brightnessfilter {
width:700px;
height:465px;
background-image:url('http://i42.tinypic.com/351dff5.jpg');
}
#brightnessfilter:hover {
-webkit-filter: brightness(1.3);
-moz-filter: brightness(1.3);
-o-filter: brightness(1.3);
-ms-filter: brightness(1.3);
}
#transparent {
position:relative;
top:400px;
width:700px;
height:65px;
background-color:rgba(0,0,0,.5);
border-radius:8px;
}
#text {
color:white;
font-weight:bold;
position:relative;
top:9px;
left:9px;
font-size:16px;
}
#replace:hover {
background-image:url('http://i40.tinypic.com/2cft7dl.jpg');
}
Above here is a link to a fiddle with my two attempts at creating the desired effect. But both have a disadvantage in using it.
Thanks in advance!
Thanks for all the help. But off course right after I posted this I came upon an idea.
I use css to change the entire divs content to brightness 1.3 and than I change the text's brightness to 0.8 to even it out.
Like this:
<div id="brightnessfilter">
<div id="transparent">
<span id="text">Random AFFECTED text (it glows)</span>
</div>
</div>
#brightnessfilter {
width:700px;
height:465px;
background-image:url('http://i42.tinypic.com/351dff5.jpg');
}
#brightnessfilter:hover {
-webkit-filter: brightness(1.3);
-moz-filter: brightness(1.3);
-o-filter: brightness(1.3);
-ms-filter: brightness(1.3);
}
#brightnessfilter:hover #text {
-webkit-filter: brightness(0.8);
-moz-filter: brightness(0.8);
-o-filter: brightness(0.8);
-ms-filter: brightness(0.8);
}
#transparent {
position:relative;
top:400px;
width:700px;
height:65px;
background-color:rgba(0,0,0,.5);
border-radius:8px;
}
#text {
color:white;
font-weight:bold;
position:relative;
top:9px;
left:9px;
font-size:16px;
}
I just dont know the correct number 0.7 seems less bright than normal 0.8 seems little to bright.