< div class = " box" > < ul> < li> < img src = " img1/1.jpg" alt = " " > </ li> < li> < img src = " img1/2.jpg" alt = " " > </ li> < li> < img src = " img1/3.jpg" alt = " " > </ li> < li> < img src = " img1/4.jpg" alt = " " > </ li> </ ul> < div class = " btns" > < a href = " javascript:;" > <</ a> < a href = " javascript:;" > ></ a> </ div> </ div>
* { margin : 0; padding : 0; list-style : none; } .box { width : 560px; height : 300px; border : 1px solid #ccc; margin : 50px auto; position : relative; } ul { width : 100%; height : 100%; position : relative; transform-style : preserve-3d; } li { width : 100%; height : 100%; position : absolute; } li:nth-child(1) { transform : translateZ ( 150px) ; } li:nth-child(2) { transform : rotateX ( 90deg) translateZ ( 150px) ; } li:nth-child(3) { transform : rotateX ( 180deg) translateZ ( 150px) ; } li:nth-child(4) { transform : rotateX ( -90deg) translateZ ( 150px) ; } .btns { width : 100%; height : 60px; position : absolute; top : 50%; transform : translateY ( -50%) translateZ ( 150px) ; } .btns a { width : 40px; height : 60px; display : block; background-color : rgba ( 0,0,0,.5) ; color : #fff; text-align : center; line-height : 60px; text-decoration : none; float : left; } .btns a:last-child { float : right; }
< script> var rBtn = document. querySelector ( '.btns a:last-child' ) ; var lBtn = document. querySelector ( '.btns a:first-child' ) ; var ul = document. querySelector ( 'ul' ) ; var i = 0 ; flag = true ; rBtn. onclick = function ( ) { if ( flag) { flag = false ; i-- ; ul. style. transform = 'rotateX(' + i* 90 + 'deg)' ; ul. style. transition = 'all 1s linear' ; } } lBtn. onclick = function ( ) { if ( flag) { flag = false ; i++ ; ul. style. transform = 'rotateX(' + i* 90 + 'deg)' ; ul. style. transition = 'all 1s linear' ; } } ul. ontransitionend = function ( ) { flag = true ; } < / script>
实现效果