我按照this tutorial将卡片翻转装在我的网站上。我学到了重要的一课,那就是不要在所有主流浏览器上进行测试就不允许your website上线,因为该动画无法在Firefox上正常工作-它会来回翻转。我知道我应该添加供应商前缀,而且我想我都知道了,但可能没有。
注意:关于如何在Firefox中进行调试的一些一般性建议也将不胜感激。我通常使用Chrome,但我对此并不满意。
的CSS
/* entire container, keeps perspective */
.flip-container {
-moz-perspective: 1000;
perspective: 1000;
}
/* flip the pane when hovered */
.flip-container:hover .flipper, .flip-container.hover .flipper {
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip-container, .front, .back {
width: 320px;
height: 480px;
margin: 10px 0 10px 0;
}
/* flip speed goes here */
.flipper {
-moz-transition: 0.6s;
transition: 0.6s;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
position: relative;
}
/* hide back of pane during swap */
.front, .back {
-moz-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
-webkit-box-shadow:
0px 0px 0px 2px rgba(0,0,0,0.6),
0px 0px 0px 14px #fff,
0px 0px 0px 18px rgba(0,0,0,0.2),
6px 6px 8px 17px #555;
-moz-box-shadow:
0px 0px 0px 2px rgba(0,0,0,0.6),
0px 0px 0px 14px #fff,
0px 0px 0px 18px rgba(0,0,0,0.2),
6px 6px 8px 17px #555;
box-shadow:
0px 0px 0px 2px rgba(0,0,0,0.6),
0px 0px 0px 14px #fff,
0px 0px 0px 18px rgba(0,0,0,0.2),
6px 6px 8px 17px #555;
}
/* front pane, placed above back */
.front {
z-index: 2;
}
/* back, initially hidden pane */
.back {
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
background-color: #99CCFF;
}
.flip-container {
-webkit-perspective: 1000;
-moz-perspective: 1000;
-o-perspective: 1000;
perspective: 1000;
margin: 20px 26px 32px 26px;
}
.flip-container, .front, .back {
width: 240px;
height: 240px;
}
.flipper {
-moz-transform: perspective(1000px);
-moz-transform-style: preserve-3d;
position: relative;
}
.front, .back {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-o-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;
}
.back {
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
.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);
}
.front {
z-index: 2;
}
html
<div class='wedding_party_row'>
<div class='wedding_party_row_contents'>
<div class = 'wedding_party_header'>
The Officiant
</div>
<div class='wedding_party_member'>
<div class="flip-container" ontouchstart="this.classList.toggle('onmouseover');">
<div class="flipper">
<div class="front">
<div class="party_image"><img /></div>
</div>
<div class="back">
<div class="party_text_container">
<div class="party_text">Blah blah</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
最佳答案
假设您尝试进行一次翻转:
与David Walsh的示例相比,您尝试一次完成太多轮换。
我已经注释掉后面的transform: rotate
规则,因此它在Firefox中有效。
使用清理编辑更新的jsfiddle
参见我的jsfiddle:http://jsfiddle.net/Volker_E/n27qM/4/
我还在jsfiddle中添加了一些注释,以获取更好的代码,例如摆脱-moz-box-shadow(仅适用于Fx
关于您的一般建议问题:Firefox自己的开发人员工具是一个不错的开始,但我认为最好的工具是Firebug。有关两者的比较,请参见What unique features does Firebug have that are not built-in to Firefox?
或者将您的代码不仅放在您的问题中,而且放在jsfiddle上,以便其他人可以立即摆弄! ;)
关于javascript - 翻转动画在Firefox上不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20125246/