1
下面的代码是一个jquery脚本,使点击时内容翻转,此代码中的所有内容均可正常工作,但翻转方向从右向左,然后从左向右翻转,如何设置方向以使其翻转一个方向, 右到左?如何在jquery中设置翻转方向?
var topCard = 1;
var facingUp = true;
var totalFaces = $('#flip-content .contents').length;
function flipCard(n) {
// Replace the contents of the current back-face with the contents
// of the element that should rotate into view.
var curBackFace = $('.' + (facingUp ? 'face2' : 'face1'));
var nextContent = $('#flip-content' + n).html();
var nextContent = $('#flip-content .contents:nth-child(' + n + ')').html();
curBackFace.html(nextContent);
// Rotate the content
$('.card').toggleClass('flipped');
facingUp = !facingUp;
if (topCard === totalFaces) {
topCard = 0;
}
}
$('#flip-content').on('click', function() {
topCard++;
flipCard(topCard);
});
$(document).ready(function() {
// Add the appropriate content to the initial "front side"
var frontFace = $('.face1');
var frontContent = $('#flip-content .contents:first-child').html();
frontFace.html(frontContent);
});
我可以忽略它,还是在您的代码段中没有定义翻转动画? :)所有输入的代码似乎都是有效的,但根据我的理解,卡片不会被视觉翻转。有一件事,你使用'var nextContent'两次。问题中的错误或代码中的错误? :) – Flater
我猜你正在使用'css3'? – Spokey
是的,我使用css3 –