CSS transition: fade background color, resetting after

前端 未结 3 857
耶瑟儿~
耶瑟儿~ 2021-01-31 03:43

I have a list of divs and allow my user to add a new one dynamically by posting new content. If the user posts new content, I\'d like to highlight it on the screen by fading the

3条回答
  •  半阙折子戏
    2021-01-31 03:51

    You could make use of animation keyframes. No additional javascript needed.

    $('input[type=button]').click( function() {
     $('#newContent').addClass('backgroundAnimated');
    });
    @-o-keyframes fadeIt {
      0%   { background-color: #FFFFFF; }
      50%  { background-color: #AD301B; }
      100% { background-color: #FFFFFF; }
    }
    @keyframes fadeIt {
      0%   { background-color: #FFFFFF; }
      50%  { background-color: #AD301B; }
      100% { background-color: #FFFFFF; }
    }
    
    .backgroundAnimated{    
        background-image:none !important; 
             -o-animation: fadeIt 5s ease-in-out; 
                animation: fadeIt 5s ease-in-out; 
    }
    
    
    Old stuff
    Old stuff
    Old stuff
    New stuff, just added

提交回复
热议问题