Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A tutorial on the method of realizing the Special effects of flipping Books with Native JS

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the "native JS to achieve special effects method tutorial", in the daily operation, I believe that many people have doubts in the native JS realization of the special effects method tutorial. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the questions of "native JS realization special effects method tutorial". Next, please follow the editor to study!

The effect is as follows:

The implementation code is as follows, you are welcome to copy and paste.

Native JS implements special effects of flipping books * {margin: 0; padding: 0; list-style: none;} # btn {width: 50px; height: 40px; line-height: 40px; position: relative Left: 50%; margin-left:-25px; top: 100px;} # book {width: 600px; height: 400px; position: absolute; left: 50%; top: 50% Margin:-200px 00-300px; border: 1px solid black; / * first cover * / background: url (images/0.jpg);} # rightPage {width: 50%; height: 100%; position: absolute Left: 50%; z-index: 2; transition: 0.5s; transform: perspective (800px) rotateY (0px); transform-origin: left center; background: black; transform-style: preserve-3d } # rightPage # topNode {position: absolute; width: 100%; height: 100%; / * first cover * / background: url (images/0.jpg) 300px 0; transform: translateZ (1px) } # rightPage # bottomNode {position: absolute; width: 100%; height: 100%; / * third cover * / background: url (images/2.jpg) 00 / * scaleX restores mirrored images after flipping books * / transform: translateZ (- 1px) scaleX (- 1);} # rightOtherPage {position: absolute; left: 50%; height: 100%; width: 50% / * third cover * / background: url (images/2.jpg) 300px 0; z-index: 1;} var index = 0 Var flag = false; btn.onclick = function () {if (flag) return; flag = true; index++; rightPage.style.transition = '0.5s; rightPage.style.transform =' perspective (800px) rotateY (- 180deg)' SetTimeout (function () {/ / change the background of the next page immediately after turning the page book.style.backgroundImage = 'url (images/' + (index% 2 + 1) +' .jpg)'; / / Let the page turn back instantly rightPage.style.transition = '0s' RightPage.style.transform = 'perspective (800px) rotateY (0deg)'; / / change the front background of the page topNode.style.backgroundImage = 'url (images/' + (index% 2 + 1) +' .jpg)' / / change the background on the back of the flip paper bottomNode.style.backgroundImage = 'url (images/' + ((index + 1)% 2 + 1) +' .jpg)'; / / change the background of the flipped paper rightOtherPage.style.backgroundImage = 'url (images/' + ((index + 1)% 2 + 1) +' .jpg)' Flag = false;}, 500);}; at this point, the study on the "tutorial on the implementation of special effects for flipping books with native JS" is over. I hope to be able to solve your 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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report