我用 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 来展示错误
提前致谢
更新:我在 4 台运行最新版本的 firefox 的不同计算机(windows 和 mac OS)上进行了测试,所有计算机上的结果都一样。
最佳答案
由于您声明了 rotateY(-180deg)
,因此浏览器可以选择翻转卡片时选择的方向(旋转可以从左或从右进行)。
Chrome“不小心”为两个面采用了正确的方向,而 firefox 为背面采用了相反的方式。采用 rotateY(-179deg)
(或 rotateY(181deg)
)将强制 Firefox 使用相同的方向。
但是,更好的方法是让面部保持原样,而不是为父级设置动画!此外,您不需要 javascript(它引入的代码少得多:pure css example)!
This article about 3d transforms当我开始接触 3d 变换的东西时帮助了我很多。这绝对值得一读。
关于jquery - Firefox 中的 CSS3 翻转动画错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17092462/