我正在使用TransformJS旋转一个div,其中包含onclick事件。该div沿其y轴旋转180度,因此翻转到窗口的另一侧。我的问题是:是否有任何方法可以在翻转后显示单独的背景颜色和文本?即使您翻转了元素,如链接http://jsfiddle.net/kSR9H/1/中所示,背景仍然是红色的,我无法找出如何在背面放置文本。
$("p").click(function() {
$(this).animate({
rotateY: "+=" + (Math.PI) / 2
}, 500, function() {
$(this).toggleClass('flipped'); // toggle class while the flip is in the middle
}).animate({
rotateY: "+=" + (Math.PI) / 2
}, 500);
});
演示地址:http://jsfiddle.net/gaby/kSR9H/2/
(Math.PI) / 2
(除以2)