CSS display none and opacity animation with keyframes not working

前端 未结 8 2026
广开言路
广开言路 2020-12-01 10:43

I have a very basic piece of HTML with the objective of animating from display: none; to display: block with opacity changing from 0 to 1.

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 11:44

    Just use position: fixed and drop the z-index: -5 at the end of the @keyframe animation (you can do any negative index....

    CSS:

    @keyframes fadeOut {
      0% { opacity: 1
    
      }
      99% {
        opacity: 0;
        z-index: 1;
      }
      100%{
        opacity: 0;
        display:none;
        position: fixed;
        z-index: -5;
      }
    }
    

提交回复
热议问题