我在点击时有一个 3d 卡片翻转动画,但触发时间太长,我不知道为什么。
请参阅此处的示例(向下滚动并单击任何黑白图片)
http://www.grancomunicaciones.com/nueva/
这是我的代码:
CSS
.flip-container {
-webkit-perspective: 1000;
-moz-perspective: 1000;
perspective: 1000;
border: 0px solid #ccc;
}
.flip-container:hover .flipper, .flip-container.hover .flipper, #flip-toggle.flip .flipper {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
filter: FlipH;
-ms-filter: "FlipH";
}
.flip-container, .front, .back {
width: 320px;
height: 427px;
}
.flipper {
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-moz-transition: 0.6s;
-moz-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
.front, .back {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front {
background: lightgreen;
z-index: 2;
}
.back {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.front .name {
font-size: 2em;
display: inline-block;
background: rgba(33, 33, 33, 0.9);
color: #f8f8f8;
font-family: Courier;
padding: 5px 10px;
border-radius: 5px;
bottom: 60px;
left: 25%;
position: absolute;
text-shadow: 0.1em 0.1em 0.05em #333;
-webkit-transform: rotate(-20deg);
-moz-transform: rotate(-20deg);
transform: rotate(-20deg);
}
.back-logo {
position: absolute;
top: 40px;
left: 90px;
width: 160px;
height: 117px;
background: url(logo.png) 0 0 no-repeat;
}
.back-title {
font-weight: bold;
color: #00304a;
position: absolute;
top: 180px;
left: 0;
right: 0;
text-align: center;
text-shadow: 0.1em 0.1em 0.05em #acd7e5;
font-family: Courier;
font-size: 2em;
}
.back p {
position: absolute;
bottom: 40px;
left: 0;
right: 0;
text-align: center;
padding: 0 20px;
}
/* vertical */
.vertical.flip-container {
position: relative;
}
.vertical .back {
-webkit-transform: rotateX(180deg);
-moz-transform: rotateX(180deg);
transform: rotateX(180deg);
}
.vertical.flip-container .flipper {
-webkit-transform-origin: 100% 213.5px;
-moz-transform-origin: 100% 213.5px;
transform-origin: 100% 213.5px;
}
.vertical.flip-container:hover .flipper {
-webkit-transform: rotateX(-180deg);
-moz-transform: rotateX(-180deg);
transform: rotateX(-180deg);
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
JS
function rotate(id) {
$("#behind").load("person.php?id="+id,function(){
document.querySelector('#flip-toggle').classList.toggle('flip');
});
}
HTML
<div class="flip-container" id="flip-toggle">
<div class="flipper">
<div class="front" id="front" style="background: url(imagenes/fotos.jpg); background-size:100%; overflow:hidden">
Front content
</div>
<div class="back" id="atras">
Back content
</div>
</div>
</div>
<div id="bot1" style="visibility:visible; position:relative; z-index:5; cursor:pointer; float:left;" onClick="rotate('1');"></div>
也许有更简单的方法?我需要实际的 3D 旋转而不是仅模拟它的 polifill(我需要在动画期间可以查看内容)。
非常感谢您的帮助,谢谢!