<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <style> #my3dSpace { -webkit-perspective: 800px; -webkit-perspective-origin: 50% 50%; overflow: hidden; } #pageGroup { width: 800px; height: 800px; margin: 0 auto; -webkit-transform-style: preserve-3d; position: relative; z-index: 100; } .page { width: 360px; height: 360px; padding: 20px; background-color: #2e6da4; color: #eeeeee; font-size: 360px; font-weight: bold; line-height: 360px; text-align: center; top: 150px; position: absolute; -webkit-transform-origin: right; -webkit-transition: 1.5s linear; } .page:hover { cursor: pointer; } </style> </head> <body> <div id="my3dSpace"> <div id="pageGroup"> <div class="page" id="page5" onclick="flip('page5')">5</div> <div class="page" id="page4" onclick="flip('page4')">4</div> <div class="page" id="page3" onclick="flip('page3')">3</div> <div class="page" id="page2" onclick="flip('page2')">2</div> <div class="page" id="page1" onclick="flip('page1')">1</div> </div> </div> <script> var leftPage = 5, rightPage = 0; function flip(id) { var page = document.getElementById(id); //初始无rotate值,page向右翻页 if (page.style.webkitTransform == "") { page.style.webkitTransform = "rotateY(180deg)"; rightPage++; leftPage--; page.style.zIndex = 1000+rightPage*100; } //判断rotate值等于180度,page向左翻页 else if (page.style.webkitTransform == "rotateY(180deg)") { page.style.webkitTransform = "rotateY(0deg)"; rightPage--; leftPage++; page.style.zIndex = 1000+leftPage*100; } //判断rotate值等于0度,page向右翻页 else if (page.style.webkitTransform == "rotateY(0deg)") { page.style.webkitTransform = "rotateY(180deg)"; rightPage++; leftPage--; page.style.zIndex = 1000+rightPage*100; } } </script> </body> </html>
为什么翻页到右边后,page5的z-index是1500,却被page1覆盖,但是点击时,是page5向左侧翻页,求大神帮解决下
是page5的更高,但是被page1覆盖啊
page5的更高