我跟着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>
答案 0 :(得分:1)
假设您正试图让只是翻转:
与David Walsh的例子相比,你试图一次完成太多的轮换
我已经注释掉了后面的transform: rotate
规则,因此它适用于Firefox。
使用清理编辑更新的jsfiddle
见我的jsfiddle:http://jsfiddle.net/Volker_E/n27qM/4/
我还在我的jsfiddle中为更好的代码添加了一些注释,比如摆脱-moz-box-shadow (仅适用于Fx&lt; 4.0)或不包含值单位值为'0'等等。
关于一般建议的问题:Firefox自己的开发者工具是一个良好的开端,但我认为最好的工具是Firebug。两者的比较见What unique features does Firebug have that are not built-in to Firefox?
或者不仅把你的代码放在你的问题上,还放在jsfiddle上,这样别人就可以立即开始摆弄! ;)