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:

desired hover effect

however, effect this:

current hover effect

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

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

php - How do you embed a video into a custom theme on WordPress? -