CSS3 transition fadein with display:none

后端 未结 5 872
野性不改
野性不改 2021-02-07 10:34

I\'ve got some element I want to fade with CSS3. It can be simply done by 2 classes with opacity: 0 and opacity: 1, b

5条回答
  •  花落未央
    2021-02-07 11:09

    You can do it by 100% CSS pure code.

    .menu > li > ul{
        display: none;
    }
    .menu > li:hover > ul {
        display: block;
        animation-duration: 0.5s;
        animation-name: fadeInFromNone;
        animation-fill-mode: forwards;
        -webkit-animation-duration: 0.5s;
        -webkit-animation-name: fadeInFromNone;
        -webkit-animation-fill-mode: forwards;
        -ms-animation-duration: 0.5s;
        -ms-animation-name: fadeInFromNoneIE;
        -ms-animation-fill-mode: forwards;
    }
    @-webkit-keyframes fadeInFromNone {
        0% {
            opacity: 0
        }
    
        1% {
            opacity: 0
        }
    
        100% {
            opacity: 1
        }
    }
    
    @keyframes fadeInFromNoneIE {
        0% {
            opacity: 0
        }
    
        1% {
            opacity: 0
        }
    
        100% {
            opacity: 1
        }
    }
    
    @keyframes fadeInFromNone {
        0% {
            opacity: 0
        }
    
        1% {
            opacity: 0
        }
    
        100% {
            opacity: 1
        }
    }
    

提交回复
热议问题