How to realize the effect of digital page turning with transform in JavaScript
This article mainly introduces "how to achieve digital page turning effect in transform in JavaScript". In daily operation, I believe that many people have doubts about how to achieve digital page turning effect in JavaScript. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for everyone to answer the doubt of "how to achieve digital page turning effect in JavaScript". Next, please follow the editor to study!
Effect picture:
Figure (1) initial diagram
Figure (2) the process of turning pages
Figure (3) result of turning the page
The code is as follows:
Transition # container {width:500px; height:500px; margin:20px auto; background:#ff0000;-webkit-transiton:background 2s linear,width 2s department height 2s;-moz-transition:background 2s magistral width 2s department height 2s;-o-transition:background 2s magistral width 2s department height 2s;-ms-transition:background 2s recital width 2s department height 2s; transition:background 2s force width 2s department height 2s;} # container:hover {background:# 00ff00misswidthplace200px height;} # my3dspace {- webkit-perspective:800 -webkit-perspective-origin:50% 50%; overflow: hidden;} # pagegroup {width: 400px; height: 400px; margin: 0 auto;-webkit-transform-style:preserve-3d; position: relative;} .page {width: 360px; height: 360px; padding: 20px; background-color: black; color: white; font-size: 360px; font-weight: blod; line-height: 360px; text-align: center; position: absolute;} # page1 {- webkit-transform-origin:top; transform-origin:top -webkit-transition:-webkit-transform 1s linear; transition:transform 1s linear;} # page2,#page3,#page4,#page5,#page6 {- webkit-transform-origin:top; transform-origin:top;-webkit-transition:-webkit-transform 1s linear; transition:transform 1s linear;-webkit-transform:rotateX (- 90deg); transform:rotateX (- 90deg);} # op {text-align: center; margin: 40px auto;} 1 2 3 4 5 6 next prev var curIndex = 1 Function next () {if (curIndex==6) return; var curPage = document.getElementById ("page" + curIndex); curPage.style.webkitTransform= "rotateX (90deg)"; curPage.style.transform = "rotateX (90deg)"; curIndex + +; var nextPage = document.getElementById ("page" + curIndex); nextPage.style.webkitTransform= "rotateX (0deg)"; nextPage.style.transform= "rotateX (0deg)";} function prev () {if (curIndex==1) return; var curPage = document.getElementById ("page" + curIndex); curPage.style.webkitTransform= "rotateX (- 90deg)" CurPage.style.transform= "rotateX (- 90deg)"; curIndex--; var prevPage = document.getElementById ("page" + curIndex); prevPage.style.webkitTransform= "rotateX (0deg)"; prevPage.style.transform= "rotateX (0deg)";} at this point, the study on "how to achieve the effect of digital page flipping in JavaScript" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!