2
A
回答
2
試試這個出來!
要在其旋轉與內容的div
http://jsfiddle.net/lakario/VPjX9/
$('#go').click(function() {
var page1 = $('.page1');
var page2 = $('.page2');
var toHide = page1.is(':visible') ? page1 : page2;
var toShow = page2.is(':visible') ? page1 : page2;
toHide.removeClass('flip in').addClass('flip out').hide();
toShow.removeClass('flip out').addClass('flip in').show();
});
0
嘗試了這一點!它一定會工作!
HTML內容
<button type="button" id="go">FLIP</button>
<div class="container">
<div class="page1">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque euismod mauris metus, ac consectetur felis. Cras consectetur, est vel malesuada faucibus, ligula enim suscipit elit, ut ornare quam urna quis felis. In hac habitasse platea dictumst.
</div>
<div class="page2">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis interdum, odio vel condimentum varius, nibh nunc ultrices velit, vestibulum consequat arcu libero eget nibh. Integer sed nibh velit.
</div>
</div>
JS內容
$('#go').click(function() {
var page1 = $('.page1');
var page2 = $('.page2');
var toHide = page1.is(':visible') ? page1 : page2;
var toShow = page2.is(':visible') ? page1 : page2;
toHide.removeClass('flip in').addClass('flip out').hide();
toShow.removeClass('flip out').addClass('flip in').show();
});
CSS內容
.page1,.page2 {
color: white;
padding: 10px;
}
/* end */
.container {
position: absolute;
-webkit-perspective: 1000;
-moz-perspective: 1000;
}
.page1 {
width: 300px;
height: 300px;
background: red;
position: relative;
}
.page2 {
width: 300px;
height: 300px;
background: blue;
position: relative;
display: none;
}
.flip {
-webkit-backface-visibility:hidden;
-webkit-transform:translateX(0);
-moz-backface-visibility:hidden;
-moz-transform:translateX(0);
}
.flip.out {
-webkit-transform: rotateY(-90deg) scale(.9);
-webkit-animation-name: flipouttoleft;
-webkit-animation-duration: 175ms;
-moz-transform: rotateY(-90deg) scale(.9);
-moz-animation-name: flipouttoleft;
-moz-animation-duration: 175ms;
}
.flip.in {
-webkit-animation-name: flipintoright;
-webkit-animation-duration: 225ms;
-moz-animation-name: flipintoright;
-moz-animation-duration: 225ms;
}
.flip.out.reverse {
-webkit-transform: rotateY(90deg) scale(.9);
-webkit-animation-name: flipouttoright;
-moz-transform: rotateY(90deg) scale(.9);
-moz-animation-name: flipouttoright;
}
.flip.in.reverse {
-webkit-animation-name: flipintoleft;
-moz-animation-name: flipintoleft;
}
@-webkit-keyframes flipouttoleft {
from { -webkit-transform: rotateY(0); }
to { -webkit-transform: rotateY(-90deg) scale(.9); }
}
@-moz-keyframes flipouttoleft {
from { -moz-transform: rotateY(0); }
to { -moz-transform: rotateY(-90deg) scale(.9); }
}
@-webkit-keyframes flipouttoright {
from { -webkit-transform: rotateY(0) ; }
to { -webkit-transform: rotateY(90deg) scale(.9); }
}
@-moz-keyframes flipouttoright {
from { -moz-transform: rotateY(0); }
to { -moz-transform: rotateY(90deg) scale(.9); }
}
@-webkit-keyframes flipintoleft {
from { -webkit-transform: rotateY(-90deg) scale(.9); }
to { -webkit-transform: rotateY(0); }
}
@-moz-keyframes flipintoleft {
from { -moz-transform: rotateY(-90deg) scale(.9); }
to { -moz-transform: rotateY(0); }
}
@-webkit-keyframes flipintoright {
from { -webkit-transform: rotateY(90deg) scale(.9); }
to { -webkit-transform: rotateY(0); }
}
@-moz-keyframes flipintoright {
from { -moz-transform: rotateY(90deg) scale(.9); }
to { -moz-transform: rotateY(0); }
}
+0
沒有工作,如果你的jsfiddle提供它,然後它爲我好 – user3136255
0
我更新了你的代碼,它的工作,按您的需求。 http://jsfiddle.net/R6fzF/437/
你的代碼有一些錯誤。首先是你沒有關閉div標籤。 div應該結束。 在你的javascript代碼中,你正在選擇單獨的div。更好的方式將分配一個共同的類,然後使用類選擇器如:$(「 common_class‘),或者你也可以使用div標籤中選擇像$(’格」)
$(function() {
var $elie = $("div");
rotate(90);
function rotate(degree) {
$elie.css({ WebkitTransform: 'rotate(' + degree + 'deg)'});
$elie.css({ '-moz-transform': 'rotate(' + degree + 'deg)'});
timer = setTimeout(function() {
rotate(++degree);
},5);
}
});
相關問題
- 1. 讓兩個對象同時旋轉
- 2. jQuery - 在點擊div時同時調整和旋轉轉換
- 3. 如何旋轉一個div
- 4. JQuery-順時針旋轉div並逆時針旋轉
- 5. 連接兩個表,並同時旋轉的SQL Server 2008
- 6. 如何旋轉一個div,而jQuery的動畫同一div
- 7. jQuery Div旋轉?
- 8. CSS旋轉。旋轉div但保持完全相同的座標?
- 9. 同時旋轉多個元素
- 10. CSS - 旋轉div -90deg - 同花順
- 11. 旋轉兩個球體
- 12. 串聯柱同時旋轉
- 13. HTML - CSS旋轉Div 180度不旋轉
- 14. 圖像不旋轉div內的旋轉
- 15. 第二次點擊時旋轉DIV緩慢旋轉
- 16. 如何旋轉div
- 17. 旋轉div元素
- 18. 居中旋轉Div
- 19. 在旋轉的div
- 20. 旋轉DIV元素
- 21. DIV旋轉正確
- 22. 鼠標旋轉div
- 23. 位置旋轉div
- 24. 使用JQuery UI同時滑動兩個div,同時進行css轉換
- 25. 在div中旋轉一個形狀,同時讓另一個div停留在同一地方
- 26. javascript - 爲什麼兩個div都不旋轉?
- 27. 動畫不同時間的兩個div
- 28. JQueryUI:同時滑動兩個div
- 29. 同時滾動兩個div jQuery中
- 30. 如何同時轉換2個div?
它看起來不錯 –
呀,這是件好事。實際上,如果你想使用動畫兩個div –