我已经为卡片翻转编写了代码。
在这里,卡片翻转旋转(3D旋转)在chrome,firebox,Internet Explorer中运行良好,但是当我在 safari 中打开它时,卡片翻转旋转效果不佳。
在safari(版本> 8.0.0 )中,卡片会旋转,但 3d动画不会。
如果你们有任何解决方案,请告诉我。
以下是代码:
$(".btn").click(function() {
$("#card").toggleClass("flipped");
});

.container {
width: 200px;
height: 260px;
position: relative;
perspective: 800px;
-webkit-perspective: 800px;
-o-perspective: 800px;
-moz-perspective: 800px;
}
#card {
width: 100%;
height: 100%;
position: absolute;
transform-style: preserve-3d;
transition: transform 1s;
-webkit-transform-style: preserve-3d;
-webkit-transition: transform 1s;
-o-transform-style: preserve-3d;
-o-transition: transform 1s;
-moz-transform-style: preserve-3d;
-moz-transition: transform 1s;
}
#card figure {
margin: 0;
display: block;
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-o-backface-visibility: hidden;
}
#card .front {
background: red;
font-size: 36px;
}
#card .back {
font-size: 36px;
background: blue;
transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
}
#card.flipped {
transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="container">
<div id="card">
<figure class="front">1</figure>
<figure class="back">2</figure>
</div>
</section>
<button class="btn"><span>Flip card</span>
</button>
&#13;
答案 0 :(得分:1)
您忘了在webkit和其他浏览器中添加前缀
-webkit-transition: -webkit-transform 1s;
$(".btn").click(function() {
$("#card").toggleClass("flipped");
});
&#13;
.container {
width: 200px;
height: 260px;
position: relative;
perspective: 800px;
-webkit-perspective: 800px;
-o-perspective: 800px;
-moz-perspective: 800px;
}
#card {
width: 100%;
height: 100%;
position: absolute;
transform-style: preserve-3d;
transition: transform 1s;
-webkit-transform-style: preserve-3d;
-webkit-transition: -webkit-transform 1s;
-o-transform-style: preserve-3d;
-o-transition: -o-transform 1s;
-moz-transform-style: preserve-3d;
-moz-transition: -moz-transform 1s;
}
#card figure {
margin: 0;
display: block;
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-o-backface-visibility: hidden;
}
#card .front {
background: red;
font-size: 36px;
}
#card .back {
font-size: 36px;
background: blue;
transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
}
#card.flipped {
transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="container">
<div id="card">
<figure class="front">1</figure>
<figure class="back">2</figure>
</div>
</section>
<button class="btn"><span>Flip card</span>
</button>
&#13;