In Angular 2, is it possible to fadeIn / fadeout instead of [hidden='xxx]?

后端 未结 5 2030
有刺的猬
有刺的猬 2021-02-02 10:46

In Angular 2, is it possible to fadeIn / fadeout instead of [hidden=\'xxx]?

I have snippet of

and wa

5条回答
  •  佛祖请我去吃肉
    2021-02-02 11:15

    Css only solution. Add class 'step' and [class.show]="fadeInIfTrue" to block you want to fade.

    css:

    .step {
      display: none;
      opacity: 0;
    
      &.show {
        display: block;
        transform: scale(1);
        opacity: 1;
        animation: anim .7s ease-in-out;
      }
    }
    
    @keyframes anim {
      0% {
        display: none;
        opacity: 0;
      }
      1% {
        display: block;
        opacity: 0;
        transition: .7s ease-in-out all;
      }
      100% {
        opacity: 1 !important;
      }
    }
    

    source - https://jdsteinbach.com/css/snippet-animate-display-transform/

提交回复
热议问题