更新:我设置了一个小提琴,它似乎工作正常 - 第一次滑入的部分包含谷歌地图 - 我想知道这是否真的是问题......
我最近在我正在开发的 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 上都进行了测试,结果是一样的。任何想法将不胜感激。