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 –