Is it possible to change only the alpha of a rgba background colour on hover?

后端 未结 14 2214
离开以前
离开以前 2020-11-29 07:04
14条回答
  •  一整个雨季
    2020-11-29 07:34

    simple solution :

    a
    {
        position: relative;
        display:inline-block;
        background: rgba(red, 0.75);
        padding: 20px;
    
    
       &:before
       {
         content: ' ';
         position: absolute;
         left: 0;
         top: 0;
         width: 100%;
         height: 100%;
       }
    
       &:hover
       {
         &:before
         {
           background-color: rgba(#000, 0.25); 
         }
       }
    }
    

    exemple : https://jsfiddle.net/epwyL296/14/

    just play with alpha of background. if you want light instead of darkness, just replace #000 by #fff

提交回复
热议问题