Dynamically change color to lighter or darker by percentage CSS (Javascript)

后端 未结 24 1737
-上瘾入骨i
-上瘾入骨i 2020-11-28 01:12

We have a big application on the site and we have a few links which are, let\'s say blue color like the blue links on this site. Now I want to make some other links, but wit

24条回答
  •  無奈伤痛
    2020-11-28 01:35

    One outdated simple answer (in 2013) was to use a 50% transparent white PNG over the color:

    div {
        background-color:red;
    }
    
    div:hover {
        background-image:url('lighten.png');
    }
    

    Where lighten.png is a PNG of a white fill with 50% transparency.

    There's much better ways to do this today. I hope people stop commenting now.

提交回复
热议问题