css3 - How to use CSS to create an image overlay effect? -
i've designed hyperlinks css add background image (to make button) using following code:
<a class="btnimg" id="btnimgconfig" href="#"></a>
.btnimg { width:100px; height:100px; display:inline-block; border:1px solid #e4e4e4; } .btnimg:hover { opacity: .2; background-color: #878787; } #btnimgconfig { background: url("http://www.icecub.nl/images/config.png") no-repeat scroll 0 0 transparent; }
as can see, i'm trying create darker effect on image on hover. desired effect:
however, effect this:
know replacing image on hover darker version of it. somehow feel shouldn't way in case. besides mentioned above, i've tried rgba{..}
on hover. had no effect @ all.
here's jsfiddle of code above.
you alternatively use pseudo-element overlays. give effect require.
.btnimg { width: 100px; height: 100px; display: inline-block; border: 1px solid #e4e4e4; position: relative; } .btnimg:hover::after { background-color: #878787; opacity: 0.4; position: absolute; content: ''; width: 100%; height: 100%; } #btnimgconfig { background: url("http://www.icecub.nl/images/config.png") no-repeat scroll 0 0 transparent; }
<a class="btnimg" id="btnimgconfig" href="#"></a>
Comments
Post a Comment