CSS Flip Transition Between Two
's

后端 未结 3 1145
长发绾君心
长发绾君心 2021-01-20 21:37

I have created a flip transition between two divs using the following css...

.flip-container {
    -webkit-perspectiv         


        
3条回答
  •  醉梦人生
    2021-01-20 22:09

    I have the same problem earlier with card flip , now i have got the solution for all the browsers for card flip even for IE10 fixes. i have written for hover please use the required code as per yours requirement.

    HTMl Strucrure

    front
    back

    css

    .flip-container {
        -webkit-perspective: 1000;
        -moz-perspective: 1000;
        -o-perspective:1000;
        -ms-perspective: 1000;
        perspective: 1000;
    
        -ms-transform: perspective(1000px);
        -moz-transform: perspective(1000px);
        -moz-transform-style: preserve-3d; 
        -ms-transform-style: preserve-3d; 
    
    }
    
    
    
        /* for IE */
    .flip-container:hover .back, .flip-container.hover .back {
        -webkit-transform: rotateY(0deg);
        -moz-transform: rotateY(0deg);
        -o-transform: rotateY(0deg);
        -ms-transform: rotateY(0deg);
        transform: rotateY(0deg);
    }
    
    .flip-container:hover .front, .flip-container.hover .front {
        -webkit-transform: rotateY(180deg);
        -moz-transform: rotateY(180deg);
        -o-transform: rotateY(180deg);
        transform: rotateY(180deg);
    }
    
    /* END: for IE */
    
    
    .flipper {
        -webkit-transition: 0.6s;
        -webkit-transform-style: preserve-3d;
        -ms-transition: 0.6s;
    
        -moz-transition: 0.6s;
        -moz-transform: perspective(1000px);
        -moz-transform-style: preserve-3d;
        -ms-transform-style: preserve-3d;
    
        transition: 0.6s;
        transform-style: preserve-3d;
    
        position: relative;
        top: 0;
        left: 0;
        width: 180px;
        height: 180px;
        -webkit-transition: all 0.4s ease-in-out;
        -moz-transition: all 0.4s ease-in-out;
        -o-transition: all 0.4s ease-in-out;
    }
    
    .front, .back {
        -webkit-backface-visibility: hidden;
        -moz-backface-visibility: hidden;
        -ms-backface-visibility: hidden;
        backface-visibility: hidden;
    
        -webkit-transition: 0.6s;
        -webkit-transform-style: preserve-3d;
    
        -moz-transition: 0.6s;
        -moz-transform-style: preserve-3d;
    
        -o-transition: 0.6s;
        -o-transform-style: preserve-3d;
    
        -ms-transition: 0.6s;
        -ms-transform-style: preserve-3d;
    
        transition: 0.6s;
        transform-style: preserve-3d;
    
        position: absolute;
        top: 0;
        left: 0;
        width: 180px;
        height: 180px;
    
    
    }
    
    .front {
        -webkit-transform: rotateY(0deg);
        -ms-transform: rotateY(0deg);
        background-position: center center;
        z-index: 2;
        background:green;
    }
    
    .back {
        background: #f2f2f2;
        -webkit-transform: rotateY(-180deg);
        -moz-transform: rotateY(-180deg);
        -o-transform: rotateY(-180deg);
        -ms-transform: rotateY(180deg);
        transform: rotateY(-180deg);
    }
    

    Demo on Jsfiddle

提交回复
热议问题