CSS 3D转换|转型后的不可原谅的内容

时间:2013-03-31 23:37:31

标签: jquery css3

Here is an example fiddle我正在尝试做的事情。

正在使用jQuery传输和CSS3 3D过渡,以便在点击时旋转2个div。如果您查看小提琴,单击“旋转”将更改div上的透视,以便显示“向后旋转”。 '后退'不可点击,因为似乎有一些时髦的z索引或定位正在进行。

HTML

<div class="masthead">
  <div class="face face-1"><span class="rotate">rotate</span></div>
  <div class="face face-2"><span class="rotate-back">rotate back</span>
</div>

JS

$(document).ready(function () {
  $(".rotate").click(function () {
    $(".masthead").transition({
        perspective: '0',
        rotateX: '90deg',
        duration: 250
    });
});
    $(".rotate-back").click(function () {
    $(".masthead").transition({
        perspective: '0',
        rotateX: '-90deg',
        duration: 250
    });
  });
});

CSS

.masthead {
    -webkit-animation-timing-function: ease-in-out;
    -webkit-transform-style: preserve-3d;
    -webkit-transform-origin: 22px 22px 0;
}
.masthead .face {
    height: 44px;
    position: absolute;
    width: 100%;
}
.masthead .face-1 {
    background: red;
    -webkit-transform: translateZ(22px);
}
.masthead .face-2 {
    background: aqua;
    -webkit-transform: rotateX(-90deg) translateZ(22px);
}

任何帮助将不胜感激,谢谢!

1 个答案:

答案 0 :(得分:0)

红色是蓝色,反之亦然。使用指针事件允许点击到达目标元素。

  $('.face-1').css('pointer-events', 'none');
  $('.face-2').css('pointer-events', '');

这是你的想法:http://jsfiddle.net/e344M/14/