In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you how to achieve 3D book page turning animation effect in html5, the content is detailed, the logic is clear, I believe most people still know too much about this knowledge, so share this article for your reference, I hope you can get something after reading this article, let's take a look at it.
This is a very cool HTML5 3D book page turning animation, the effect is relatively simple, dragging the mouse to simulate manual page turning, more beautiful is the page turning process, showing a realistic 3D effect. The text and pictures in the book will also be displayed in 3D, which is very cool.
HTML Code:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam fermentum nisl quis nulla eleifend dignissim. Curabitur varius lobortis tincidunt. Maecenas gravida, nulla quis luctus imperdiet, ipsum nibh consectetur ante, in sodales massa tortor eget neque. Donec porta ligula massa, id sagittis est. Ut nisl tellus, faucibus nec feugiat ut, laoreet iaculis felis. Suspendisse ultrices mauris vel tellus suscipit commodo. Integer vitae tortor erat. Pellentesque non tempor nisi.
CSS Code:
.book {width: 300px; height: 300px; margin-top:-150px; position: absolute; left: 50%; top: 50%;-webkit-transform: rotateX (60deg);-moz-transform: rotateX (60deg);-ms-transform: rotateX (60deg);-o-transform: rotateX (60deg); transform: rotateX (60deg);-webkit-user-select: none;-moz-user-select: none -ms-user-select: none;-o-user-select: none; user-select: none;}. Page {width: 300px; height: 300px; padding: 1mm; position: absolute; left: 0; top: 0; text-indent: 2em;} .front {background-color: # d93e2b;}. Back {background-color: # fff;}. Front-cover {cursor: move;-webkit-transform-origin: 050% -moz-transform-origin: 0 50%;-ms-transform-origin: 0 50%;-o-transform-origin: 0 50%; transform-origin: 0 50%;-webkit-transform: rotateY (0deg);-moz-transform: rotateY (0deg);-ms-transform: rotateY (0deg);-o-transform: rotateY (0deg); transform: rotateY (0deg);} .front-cover .back {background-image: url (mdn.png) Background-repeat: no-repeat; background-position: 50% 50%;-webkit-transform: translateZ (3px);-moz-transform: translateZ (3px);-ms-transform: translateZ (3px);-o-transform: translateZ (3px); transform: translateZ (3px);} .back-cover .back {- webkit-transform: translateZ (- 3px);-moz-transform: translateZ (- 3px);-ms-transform: translateZ (- 3px) -o-transform: translateZ (- 3px); transform: translateZ (- 3px);} .p3D {- webkit-transform-style: preserve-3d;-moz-transform-style: preserve-3d;-ms-transform-style: preserve-3d;-o-transform-style: preserve-3d; transform-style: preserve-3d;}. Flip {- webkit-transform: rotateY (180deg);-moz-transform: rotateY (180deg);-ms-transform: rotateY (180deg) -o-transform: rotateY (180deg); transform: rotateY (180deg);} .dino, .shadow {width: 196px; height: 132px; position: absolute; left: 60px; top: 60px;-webkit-transform-origin: 0 100%;-moz-transform-origin: 0 100%;-ms-transform-origin: 0 100%;-o-transform-origin: 0 100%; transform-origin: 0 100% }. Dino {background: url (dino.png) no-repeat;}. Shadow {background: url (shadow.png) no-repeat;}
JavaScript Code:
(function (window, document) {var prefixes = ['Webkit',' Moz', 'ms',' Oleg,'], book = document.querySelectorAll ('.book') [0], page = document.querySelectorAll ('.front-cover') [0], dino = document.querySelectorAll (' .dino') [0], shadow = document.querySelectorAll ('.shadow') [0], hold = false CenterPoint = window.innerWidth / 2, pageSize = 300, clamp = function (val, min, max) {return Math.max (min, Math.min (val, max)) }; page.onmousedown = function () {hold = true;}; _ window.onmouseup = function () {if (hold) {hold = false;}}; _ window.onresize = function () {centerPoint = window.innerWidth / 2;}; _ window.onmousemove = function (evt) {if (! hold) {return } var angle = clamp ((centerPoint-evt.pageX + pageSize) / pageSize *-90,-180,0), I, j; for (I = 0, j = prefixes.length; I < j; ifixes +) {book.style [prefixes [I] + 'Transform'] =' rotateX ('+ (60 + angle / 8) + 'deg)' Page. Style [prefixes [I] + 'Transform'] =' rotateY ('+ angle + 'deg)'; Dino.style [prefixes [I] + 'Transform'] =' rotateX ('+ (angle / 2) + 'deg)'; shadow.style [prefixes [I] + 'Transform'] =' translateZ (1px) skewX ('+ (angle / 8) + 'deg)';};}) (window, document) These are all the contents of the article "how to achieve 3D book turning animation in html5". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.