Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Darken background image on hover

Tags:

html

css

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/

like image 585
John Smith Avatar asked Jul 05 '13 05:07

John Smith


People also ask

How do I darken an image on hover?

If you want to darken the image, use an overlay element with rgba and opacity properties which will darken your image...

How do I make an image hover dark in CSS?

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.

How do you make the element hover 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 ).

How do you make a background image darker in CSS?

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.


1 Answers

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

like image 88
Sabba Keynejad Avatar answered Oct 10 '22 00:10

Sabba Keynejad