gpt4 book ai didi

Safari 中的 CSS FlipCard(3d 变换)

转载 作者:太空宇宙 更新时间:2023-11-04 06:31:29 25 4
gpt4 key购买 nike

一个简单的 FlipCard 应用程序。该应用程序在 Chrome 中运行良好,但在 Safari 中运行不佳。在 Safari 中,单击后会看到卡片背面的文字,它会闪烁,然后消失。

代码的想法来自此链接:w3schools/howto/css-flip-card

HTML:

<div class='flip-card'>
<div class='flip-card-inner'>
<div class='flip-card-front'><p>1</p></div>
<div class='flip-card-back'><p>2</p></div>
</div>
</div>

CSS:

.flip-card {
perspective:1000px;
-webkit-perspective:1000px}

.flip-card-inner {
position:relative;
transition:transform 0.8s;
-webkit-transition:-webkit-transform 0.8s;
transform-style:preserve-3d;
-webkit-transform-style:preserve-3d}

.flip-card-front, .flip-card-back {
position:absolute;
backface-visibility:hidden;
-webkit-backface-visibility:hidden;}

.flip-card-back {
transform:rotateY(180deg);
-webkit-transform: rotateY(180deg);}

JS:

$('#flash-card-game').on('click',function(){FlipToBack()});

function FlipToBack(){
$('#flash-card-game').css("transform","rotateY(180deg)");
$('#flash-card-game').css("-webkit-transform","rotateY(180deg)");
setTimeout(FlipToFront,1000);}

function FlipToFront(){
$('#flash-card-game').css("transform","rotateY(0deg)");
$('#flash-card-game').css("-webkit-transform","rotateY(0deg)");}

如有任何帮助,我们将不胜感激。

最佳答案

请试试这个

$('#flash-card-game').on('click', function() {
FlipToBack()
});

function FlipToFront() {
$('#flash-card-game').removeClass("flip-to-back");
$('#flash-card-game').addClass("flip-to-front");
}

function FlipToBack() {
$('#flash-card-game').addClass("flip-to-back");
setTimeout(FlipToFront, 1000);
}
Write the folowing CSS

.flip-to-front {
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}

.flip-to-back {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}

关于Safari 中的 CSS FlipCard(3d 变换),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54639405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com