Darken background image on hover

后端 未结 14 1498
囚心锁ツ
囚心锁ツ 2020-12-22 23:03

How would I darken a background image on hover without making a new darker image?

CSS:

.image {
  background: url(\         


        
14条回答
  •  萌比男神i
    2020-12-22 23:22

    If you have to use the current image and get a darker image then you need to create a new one. Else you can simply reduce the opacity of the .image class and the in the .image:hover you can put a higher value for opacity. But then the image without hover would look pale.

    The best way would be to create two images and add the following :

    .image {
        background: url('http://cdn1.iconfinder.com/data/icons/round-simple-social-icons/58/facebook.png');
        width: 58px;
        height: 58px;
        opacity:0.9;   
    }
    .image:hover{
        background: url('http://cdn1.iconfinder.com/data/icons/round-simple-social-icons/58/facebook_hover.png');
    }
    }
    

提交回复
热议问题