CSS3 transitions want to add a colour and fade it away

前端 未结 2 1364
南笙
南笙 2021-02-01 18:20

I want to make a DIV background (which doesn\'t have a background color) flash red then ease out to blank again. now I have used JS to add a new CLASS (which adds the red) to t

2条回答
  •  礼貌的吻别
    2021-02-01 18:52

    If you want something like a highlighting you may want to use CSS3 animations. They are not supported in older browsers. Check caniuse for this.

    I've created a short example over here.

    The highlight is called on clicking the link. Here is the CSS (without vendor-prefixes):

    @keyframes highlight {
      0% {
        background: red
      }
      100% {
        background: none;
      }
    }
    
    #highlight:target {
      animation: highlight 1s;
    }
    

提交回复
热议问题