gpt4 book ai didi

jquery - -webkit 转换和 jQuery .animate() 之间的冲突

转载 作者:行者123 更新时间:2023-11-28 03:42:10 25 4
gpt4 key购买 nike

更新: 我设置了一个 fiddle ,它似乎工作正常——首先滑入的部分包含一张谷歌地图——我想知道这是否真的是问题所在……

我最近在我正在开发的 HTML5 应用程序中添加了一个 -webkit-transform 卡片翻转。不幸的是,这会使水平移动的简单旋转木马表现出一些奇怪的行为。

我的轮播结构是这样的

<div id="wrapper">
<div id="sections">
<section id="startPage" class="page">
<div id="card">
<div class="face front">
<p>Some content here</p>
<button id="flipFront">A label</button>
</div>
<div class="face back">
<p>Some content here</p>
<button id="flipBack">A label</button>
</div>
</div>
</section>
<section></section>
<section></section>
</div>
</div>

我循环通过它的 jQuery .click() 行为是这样的:

$('#sections').stop().animate({"left": -($('#someDiv').position().left)}, 500);

这工作得很好,直到我为卡片翻转添加 -webkit-transform CSS:

#startPage {
-webkit-perspective: 1000;
}

#card {
height: 940px;
width: 640px;
-webkit-transform-style: preserve-3d;
-webkit-transition: 0.5s;
}

.back {
-webkit-transform: rotateY(180deg);
background-color:#000;
}

.rotated{
-webkit-transform: rotateY(180deg);
}

.back, .front {
height: 940px;
width: 640px;
}

.face {position: absolute;-webkit-backface-visibility: hidden;}

现在我的卡片在使用时可以正常翻转

$('#setup, #back').click(function() {
$('#card').toggleClass('rotated');
});

我的旋转木马仍然有效,但似乎卡住了 - 例如它会部分滑出,并一直卡在原位,直到我以某种方式与 div 交互,之后它会卡入正确的位置。

问题好像是

-webkit-transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;

当我从 CSS 中删除它们时,轮播可以正常工作,但翻转却不行。

我在 Safari 和 Chrome 上都测试过,结果是一样的。如有任何想法,我们将不胜感激。

最佳答案

只有 webkit 转换才能搞砸,添加更多信息,如

-webkit-transform: rotateY(180deg) scale(2);
-moz-transform: rotateY(180deg) scale(2);
-o-transform: rotateY(180deg) scale(2);
-ms-transform: rotateY(180deg) scale(2);

所以它被更多的浏览器支持,你有一个后备方案。我已经多次看到这个问题,但是我不能保证,因为我没有用你的代码测试它。

关于jquery - -webkit 转换和 jQuery .animate() 之间的冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9964556/

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