CSS3 Transition - Fade out effect

后端 未结 6 2050
慢半拍i
慢半拍i 2020-11-28 22:19

I am trying to implement the \"fade out\" effect in pure CSS. Here is the fiddle. I did look into a couple of solutions online, however, after reading the documentation onli

6条回答
  •  粉色の甜心
    2020-11-28 22:31

    Since display is not one of the animatable CSS properties. One display:none fadeOut animation replacement with pure CSS3 animations, just set width:0 and height:0 at last frame, and use animation-fill-mode: forwards to keep width:0 and height:0 properties.

    @-webkit-keyframes fadeOut {
        0% { opacity: 1;}
        99% { opacity: 0.01;width: 100%; height: 100%;}
        100% { opacity: 0;width: 0; height: 0;}
    }  
    @keyframes fadeOut {
        0% { opacity: 1;}
        99% { opacity: 0.01;width: 100%; height: 100%;}
        100% { opacity: 0;width: 0; height: 0;}
    }
    
    .display-none.on{
        display: block;
        -webkit-animation: fadeOut 1s;
        animation: fadeOut 1s;
        animation-fill-mode: forwards;
    }
    

提交回复
热议问题