使用CSS创建翻转卡

时间:2014-11-09 16:05:19

标签: css internet-explorer flip

我试图用CSS制作翻转卡动画。 它在Firefox,Chrome,Opera,Safari上运行良好,但我有一个Internet Explorer问题(再次)......

看看我制作的演示:Text problem with Internet Explorer

Firefox,Chrome,Opera和Safari中没问题!

但是我的文字被Internet Explorer反转了......请告诉我代码中的错误是什么?

CSS:

 <style>
    .flip-container {
        -webkit-perspective : 680;
        -ms-perspective: 680;
        -moz-perspective: 680;
        -o-perspective: 680;
        perspective: 680;            
    }

    .flip-container:hover .flipper, .flip-container.hover .flipper  {
        -webkit-transform:rotateY(180deg);
        -moz-transform:rotateY(180deg);
        -ms-transform:rotateY(180deg);
        -o-transform:rotateY(180deg);
        transform: rotateY(180deg);
    }

    .flip-container, .front .back {
        width:480px;
        height:340px;
    }

    .flipper {
        -webkit-transform-style: preserve-3d;
        -moz-transform-style: preserve-3d;
        -ms-transform-style: preserve-3d;
        -o-transform-style: preserve-3d;
        transform-style: preserve-3d;
        -webkit-transition: 2.0s;
        -moz-transition: 2.0s;
        -ms-transition: 2.0s;
        -o-transition: 2.0s;
        transition: 2.0s;
        position: relative;
    }

    .front, .back {
        -webkit-backface-visibility: hidden;
        -moz-backface-visibility: hidden;
        -ms-backface-visibility: hidden;
        -o-backface-visibility: hidden;
        backface-visibility: hidden;
        position: absolute;
        top: 0;
        left: 0;
    }

    .front {
        z-index: 2;
        -webkit-transform: rotateY(0deg);
        -moz-transform: rotateY(0deg);
        -ms-transform: rotateY(0deg);
        -o-transform: rotateY(0deg);
        transform: rotateY(0deg);        }

    .back {
        -webkit-transform: rotateY(180deg);
        -moz-transform: rotateY(180deg);
        -ms-transform: rotateY(180deg);
        -o-transform: rotateY(180deg);
        transform: rotateY(180deg);
    }
</style>

1 个答案:

答案 0 :(得分:1)

我添加了最新Internet Explorer版本的更新。它适用于每个现代桌面浏览器。

我更正了旋转值:

初始: 前= 0° 背= -180°

悬停: 正面= 180° 后退= 0°

此代码仍需要更新才能与 IE6 IE7 IE8 兼容:

<style>
    .flip-container {
        -webkit-perspective : 680;
        -moz-perspective: 680;
        -ms-perspective: 680;
        -o-perspective: 680;
        perspective: 680;   
    }

    /* For Internet Explorer */        
    .flip-container:hover .back, .flip-container.hover .back  {            
        -webkit-transform:rotateY(0deg);
        -moz-transform:rotateY(0deg);
        -ms-transform:rotateY(0deg);
        -o-transform:rotateY(0deg);
        transform: rotateY(0deg); 
    }        

    /* For Internet Explorer */        
    .flip-container:hover .front, .flip-container.hover .front  {                     
        -webkit-transform:rotateY(180deg);
        -moz-transform:rotateY(180deg);
        -ms-transform:rotateY(180deg);
        -o-transform:rotateY(180deg);
        transform: rotateY(180deg);
    }

    .flip-container, .front .back {
        width:480px;
        height:340px;
    }

    .flipper {
        -webkit-transform-style: preserve-3d;
        -moz-transform-style: preserve-3d;
        -ms-transform-style: preserve-3d;
        -o-transform-style: preserve-3d;
        transform-style: preserve-3d;
        position: relative;
    }

    .front, .back {        
        -webkit-transform-style: preserve-3d;
        -moz-transform-style: preserve-3d;
        -ms-transform-style: preserve-3d;
        -o-transform-style: preserve-3d;
        transform-style: preserve-3d;
        -webkit-backface-visibility: hidden;
        -moz-backface-visibility: hidden;
        -ms-backface-visibility: hidden;
        -o-backface-visibility: hidden;
        backface-visibility: hidden;            
        -webkit-transition: 2.0s;
        -moz-transition: 2.0s;
        -ms-transition: 2.0s;
        -o-transition: 2.0s;
        transition: 2.0s;

        position: absolute;
        top: 0;
        left: 0;
    }

    .front {
        z-index:2;           
        -webkit-transform: rotateY(0deg);
        -moz-transform: rotateY(0deg);
        -ms-transform: rotateY(0deg);
        -o-transform: rotateY(0deg);
        transform: rotateY(0deg);
    }

    .back {
        z-index:1;
        -webkit-transform: rotateY(-180deg);
        -moz-transform: rotateY(-180deg);
        -ms-transform: rotateY(-180deg);
        -o-transform: rotateY(-180deg);
        transform: rotateY(-180deg);           
    }

</style>