1

Here is an example fiddle of what I'm trying to do.

jQuery transit and CSS3 3D transitions are being used in order to rotate 2 divs on click. If you take a look at the fiddle, clicking 'rotate' will change the perspective on the div so 'rotate back' is showing. 'rotate back' is not clickable, as there appears to be some funky z-indexing or positioning going on.

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);
}

Any help would be appreciated, thank you!

4

1 回答 1

0

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

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

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

于 2013-04-25T22:11:18.460 回答