CSS: lighten an element on hover

后端 未结 7 1920
刺人心
刺人心 2021-01-30 12:41

Assuming an element is at 100% saturation, opacity, etc... how can I have its background become slightly lighter when it is hovered?

The use case is tha

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 13:22

    It's a long time ago but you can do something like this:

    .element {
        background-color: red;
    }
    .element:hover {
        box-shadow: inset 0 0 100px 100px rgba(255, 255, 255, 0.1);
    }
    

    You can change the 100px into a number you want. I took a large one to cover the whole element.

    It isn't a very beautiful solution but it works!

    Here an example: http://jsfiddle.net/6nkh3u7k/5/

提交回复
热议问题