jquery - Firefox 中的 CSS3 翻转动画错误

标签 jquery html css

我用 css3 创建了一个翻转动画。在 webkit 浏览器上,翻转看起来不错,但在 firefox 中,翻转动画无法正常工作。可以看到翻转动画有效,但是看起来真的很“怪异”,并没有一直翻转。

我的 html:

<li class="employee">
   <div class="employee_container">
        <div class="front flip">
            <img src="http://www.piratealumni.com/s/722/images/editor/headshots/AshleyPerson.jpg" alt="">
        </div>
        <div class="back flip">
            <h2>Title</h2>
            <h3>Lorem ipsum</h3>
            <p>Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum.</p>
        </div>
    </div>
</li>

我的 CSS:

.employee {
    width:33%;
    float:left;
    display:block;
    padding:0.5em;
    height:20em;
}

.employee_container {
    height:100%;
    position:relative;
    -webkit-perspective: 800px;
    -moz-perspective: 800px;
    -ms-perspective: 800px;
    -o-perspective: 800px;
    perspective: 800px;
}

.back, .front {
    border: 3px solid #cecece;
    position:absolute;
}

.front img {
    min-height:100%;
    height:auto;
    width:100%;
}

.front {
    overflow:hidden;
    width:100%;
    height:100%;
    z-index:900;
    -webkit-transform: rotateX(0deg) rotateY(0deg);
    -webkit-transform-style: preserve-3d;
    -webkit-backface-visibility: hidden;

    -moz-transform: rotateX(0deg) rotateY(0deg);
    -moz-transform-style: preserve-3d;
    -moz-backface-visibility: hidden;

    -o-transition: all .4s ease-in-out;
    -ms-transition: all .4s ease-in-out;
    -moz-transition: all .4s ease-in-out;
    -webkit-transition: all .4s ease-in-out;
    transition: all .4s ease-in-out;
}

.active .front {
    -webkit-transform: rotateY(180deg);
    -moz-transform: rotateY(180deg);
}

.back {
    background-image: url(img/RD.png);
    background-repeat: no-repeat;
    background-position:90% 93%;
    padding:1em;
    background-color:#ecad40;
    height:100%;
    width:100%;
    z-index:800;
    -webkit-transform: rotateY(-180deg);
    -webkit-transform-style: preserve-3d;
    -webkit-backface-visibility: hidden;

    -moz-transform: rotateY(-180deg);
    -moz-transform-style: preserve-3d;
    -moz-backface-visibility: hidden;

    -o-transition: all .4s ease-in-out;
    -ms-transition: all .4s ease-in-out;
    -moz-transition: all .4s ease-in-out;
    -webkit-transition: all .4s ease-in-out;
    transition: all .4s ease-in-out;
}

.active .back {
    z-index: 1000;
    -webkit-transform: rotateX(0deg) rotateY(0deg);
    -moz-transform: rotateX(0deg) rotateY(0deg);
}

.back h3 {
    font-weight:normal;
    font-size:0.8em;
}

.back p {
    font-size:1em;
    padding-top:1em;
    border-top:1px dashed white;
    margin-top:1em;
}

我做了一个 fiddle 来展示错误

http://jsfiddle.net/vDQwQ/1/

提前致谢

更新:我在 4 台运行最新版本的 firefox 的不同计算机(windows 和 mac OS)上进行了测试,所有计算机上的结果都一样。

最佳答案

由于您声明了 rotateY(-180deg),因此浏览器可以选择翻转卡片时选择的方向(旋转可以从左或从右进行)。

Chrome“不小心”为两个面采用了正确的方向,而 firefox 为背面采用了相反的方式。采用 rotateY(-179deg)(或 rotateY(181deg))将强制 Firefox 使用相同的方向。

fixed Example

但是,更好的方法是让面部保持原样,而不是为父级设置动画!此外,您不需要 javascript(它引入的代码少得多:pure css example)!

This article about 3d transforms当我开始接触 3d 变换的东西时帮助了我很多。这绝对值得一读。

关于jquery - Firefox 中的 CSS3 翻转动画错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17092462/

相关文章:

html - 如何让 div 占用父级的剩余高度?

javascript - Bootstrap Scrollspy 导致 Off-Canavas 菜单出现问题

javascript - 引号中的字母出现在正文标记之后

javascript - 浏览器调整大小时实时更改

html - 如何在较小的div下居中较大的div

javascript - CSS3D矩阵生成

javascript - Android和IOS移动设备 :calculate browser screen height excluding address bar and navigation bar height

html - 当 div 中的图像在悬停时发生变化时,图像被截断

javascript - 如何在 JavaScript 中优雅地将函数分配给多个对象属性

javascript - 如何使用包含所有菜单项的容器获得全宽下拉区域