css transition opacity fade background

后端 未结 4 613
慢半拍i
慢半拍i 2020-12-09 08:21

I am doing a transition where it fades into transparent white, when a user is hovering an image.

My problem is that I need to change the color, that it

4条回答
  •  猫巷女王i
    2020-12-09 08:45

    Wrap your image with a span element with a black background.

    .img-wrapper {
      display: inline-block;
      background: #000;
    }
    
    .item-fade {
      vertical-align: top;
      transition: opacity 0.3s;
      -webkit-transition: opacity 0.3s;
      opacity: 1;
    }
    
    .item-fade:hover {
      opacity: 0.2;
    }
    
       
    

提交回复
热议问题