How would I darken a background image on hover without making a new darker image?
CSS:
.image { background: url('http://cdn1.iconfinder.com/data/icons/round-simple-social-icons/58/facebook.png'); width: 58px; height: 58px; }
JSFiddle link: http://jsfiddle.net/qrmqM/1/
If you want to darken the image, use an overlay element with rgba and opacity properties which will darken your image...
To sum it up : Use opacity and filter property to darken an image and create cool hover effect with it. Use RGBA colors to make your background image darker.
If you just want to transition to a darker color on :hover , you don't need linear-gradient . You could simply transition to a darker color. Also, you did not specify the transition-property (i.e, background ).
Use the background-blend-mode Property to Darken Background Image in CSS. We can use the background-blend-mode property to darken the background image in CSS. The property sets the blending mode of the background.
Similar, but again a little bit different.
Make the image 100% opacity so it is clear. And then on img hover reduce it to the opacity you want. In this example, I have also added easing for a nice transition.
img { -webkit-filter: brightness(100%); } img:hover { -webkit-filter: brightness(70%); -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -o-transition: all 1s ease; -ms-transition: all 1s ease; transition: all 1s ease; }
That will do it, Hope that helps.
Thank you Robert Byers for your jsfiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With