Reputation: 327
Just need to know how hovering an image makes it darker? using jquery /css.
my css
.img-files{
background:url("/Images/syzs.png") no-repeat;
position:absolute;
background-size:90%;
width: 100px;
height: 150px;
text-indent: -9999px;
z-index:1;
}
Upvotes: 1
Views: 5249
Reputation: 66663
You can do this using a combination of the :hover
pseudo class and the ::after
pseudo element.
<div>
<img src="http://aux3.iconpedia.net/uploads/69290979.png" />
</div>
div {
position: relative;
display: inline-block;
}
img {
width: 100px;
height: 100px;
}
div:hover::after {
position: absolute;
z-index: 1;
background-color: black;
opacity: 0.7;
left: 0;
top: 0;
height: 100%;
width: 100%;
content: '';
}
Upvotes: 3
Reputation: 157334
You can make it better using black background with opacity property
.dark {
display: inline-block;
background: black;
}
.dark img {
display: block;
transition: all 0.5s linear;
-webkit-transition: all 0.5s linear;
-moz-transition: all 0.5s linear;
-ms-transition: all 0.5s linear;
-o-transition: all 0.5s linear;
}
.dark:hover img {
opacity: 0.5;
}
Upvotes: 5
Reputation: 167182
Use opacity
:
.img-files {opacity: 0.5;}
.img-files:hover {opacity: 1;}
Upvotes: 1