


CSS realizes three-dimensional three-dimensional rotation infinite carousel animation (code example)
This article introduces CSS to realize three-dimensional three-dimensional rotation infinite carousel animation (code example). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
In the previous article [How to implement infinite carousel animation in css], we introduced the infinite carousel animation played horizontally (as shown below). In this article, we will build on the previous Modify to implement different carousel animations.
Three-dimensional rotating carousel
With some small changes, we can use different polygon shapes for images wheels, and larger images, resulting in different effects. In this case, the image is twice as large and placed in a triangular arrangement that uses less space. There are still eight identical photos in the sequence:
Using Firefox, you will see that the animation is running as well. In addition to the extra JavaScript code and replacing -webkit with -moz, we have to add -moz-transform-style:preserve-3d; to the #rotator a in the css, because it is not included Inherited (starting with Firefox v12).
This example has a slight change, we are moving the photo from the front of the queue to the back. In the former case, we move them from the back of the queue to the front.
To do this, we will change:
target.insertBefore(arr[arr.length-1], arr[0]);
into:
target.appendChild(arr[0]);
Put the complete code below:
html code:
<div id="stage3"> <div id="rotator3" style="-webkit-animation-name: rotator3; -moz-animation-name: rotator3;"> <a href="1.jpg"><img src="/static/imghwm/default1.png" data-src="1.jpg" class="lazy" style="max-width:90%" alt="CSS realizes three-dimensional three-dimensional rotation infinite carousel animation (code example)" ></a> <a href="2.jpg"><img src="/static/imghwm/default1.png" data-src="2.jpg" class="lazy" style="max-width:90%" alt="CSS realizes three-dimensional three-dimensional rotation infinite carousel animation (code example)" ></a> <a href="3.jpg"><img src="/static/imghwm/default1.png" data-src="3.jpg" class="lazy" style="max-width:90%" alt="CSS realizes three-dimensional three-dimensional rotation infinite carousel animation (code example)" ></a> <a href="4.jpg"><img src="/static/imghwm/default1.png" data-src="4.jpg" class="lazy" style="max-width:90%" alt="CSS realizes three-dimensional three-dimensional rotation infinite carousel animation (code example)" ></a> <a href="5.jpg"><img src="/static/imghwm/default1.png" data-src="5.jpg" class="lazy" style="max-width:90%" alt="CSS realizes three-dimensional three-dimensional rotation infinite carousel animation (code example)" ></a> <a href="6.jpg"><img src="/static/imghwm/default1.png" data-src="6.jpg" class="lazy" style="max-width:90%" alt="CSS realizes three-dimensional three-dimensional rotation infinite carousel animation (code example)" ></a> <a href="7.jpg"><img src="/static/imghwm/default1.png" data-src="7.jpg" class="lazy" style="max-width:90%" alt="CSS realizes three-dimensional three-dimensional rotation infinite carousel animation (code example)" ></a> <a href="8.jpg"><img src="/static/imghwm/default1.png" data-src="8.jpg" class="lazy" style="max-width:90%" alt="CSS realizes three-dimensional three-dimensional rotation infinite carousel animation (code example)" ></a> </div> </div>
css code:
#stage3 { margin: 2em auto 1em 50%; height: 240px; -webkit-perspective: 1200px; -webkit-perspective-origin: 0 90px; -moz-perspective: 1200px; -moz-perspective-origin: 0 90px; -ms-perspective: 1200px; -ms-perspective-origin: 0 90px; } #rotator3 a { position: absolute; left: -151px; -moz-transform-style: preserve-3d; } #rotator3 a img { padding: 10px; border: 1px solid #ccc; background: #fff; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -ms-backface-visibility: hidden; } #rotator3 a:nth-of-type(1) img { -webkit-transform: rotateX(-90deg) translateZ(100px); -moz-transform: rotateX(-90deg) translateZ(100px); -ms-transform: rotateX(-90deg) translateZ(100px); } #rotator3 a:nth-of-type(2) img { -webkit-transform: translateZ(100px); -moz-transform: translateZ(100px); -ms-transform: translateZ(100px); } #rotator3 a:nth-of-type(3) img { -webkit-transform: rotateX(90deg) translateZ(100px); -moz-transform: rotateX(90deg) translateZ(100px); -ms-transform: rotateX(90deg) translateZ(100px); } #rotator3 a:nth-of-type(n+4) { display: none; } @-webkit-keyframes rotator3 { from { -webkit-transform: rotateX(0deg); } to { -webkit-transform: rotateX(90deg); } } @-moz-keyframes rotator3 { from { -moz-transform: rotateX(0deg); } to { -moz-transform: rotateX(90deg); } } @-ms-keyframes rotator3 { from { -ms-transform: rotateX(0deg); } to { -ms-transform: rotateX(90deg); } } #rotator3 { -webkit-transform-origin: 0 101px; -webkit-transform-style: preserve-3d; -webkit-animation-timing-function: cubic-bezier(1, 0.2, 0.2, 1); -webkit-animation-duration: 2s; -webkit-animation-delay: 1s; -moz-transform-origin: 0 101px; -moz-transform-style: preserve-3d; -moz-animation-timing-function: cubic-bezier(1, 0.2, 0.2, 1); -moz-animation-duration: 2s; -moz-animation-delay: 1s; -ms-transform-origin: 0 101px; -ms-transform-style: preserve-3d; -ms-animation-timing-function: cubic-bezier(1, 0.2, 0.2, 1); -ms-animation-duration: 2s; -ms-animation-delay: 1s; } #rotator3:hover { -webkit-animation-play-state: paused; -moz-animation-play-state: paused; -ms-animation-play-state: paused; }
js code:
document.addEventListener("DOMContentLoaded", function() { var rotateComplete = function(e) { with(target.style) { webkitAnimationName = MozAnimationName = msAnimationName = ""; } target.insertBefore(arr[arr.length - 1], arr[0]); setTimeout(function(el) { with(el.style) { webkitAnimationName = MozAnimationName = msAnimationName = "rotator3"; } }, 0, target); }; var target = document.getElementById("rotator3"); var arr = target.getElementsByTagName("a"); target.addEventListener("webkitAnimationEnd", rotateComplete, false); target.addEventListener("animationend", rotateComplete, false); target.addEventListener("MSAnimationEnd", rotateComplete, false); }, false);
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's learning.
The above is the detailed content of CSS realizes three-dimensional three-dimensional rotation infinite carousel animation (code example). For more information, please follow other related articles on the PHP Chinese website!

ThebestmethodforincludingCSSdependsonprojectsizeandcomplexity:1)Forlargerprojects,useexternalCSSforbettermaintainabilityandperformance.2)Forsmallerprojects,internalCSSissuitabletoavoidextraHTTPrequests.Alwaysconsidermaintainabilityandperformancewhenc

What it looks like to troubleshoot one of those impossible issues that turns out to be something totally else you never thought of.

@keyframesandCSSTransitionsdifferincomplexity:@keyframesallowsfordetailedanimationsequences,whileCSSTransitionshandlesimplestatechanges.UseCSSTransitionsforhovereffectslikebuttoncolorchanges,and@keyframesforintricateanimationslikerotatingspinners.

I know, I know: there are a ton of content management system options available, and while I've tested several, none have really been the one, y'know? Weird pricing models, difficult customization, some even end up becoming a whole &

Linking CSS files to HTML can be achieved by using elements in part of HTML. 1) Use tags to link local CSS files. 2) Multiple CSS files can be implemented by adding multiple tags. 3) External CSS files use absolute URL links, such as. 4) Ensure the correct use of file paths and CSS file loading order, and optimize performance can use CSS preprocessor to merge files.

Choosing Flexbox or Grid depends on the layout requirements: 1) Flexbox is suitable for one-dimensional layouts, such as navigation bar; 2) Grid is suitable for two-dimensional layouts, such as magazine layouts. The two can be used in the project to improve the layout effect.

The best way to include CSS files is to use tags to introduce external CSS files in the HTML part. 1. Use tags to introduce external CSS files, such as. 2. For small adjustments, inline CSS can be used, but should be used with caution. 3. Large projects can use CSS preprocessors such as Sass or Less to import other CSS files through @import. 4. For performance, CSS files should be merged and CDN should be used, and compressed using tools such as CSSNano.

Yes,youshouldlearnbothFlexboxandGrid.1)Flexboxisidealforone-dimensional,flexiblelayoutslikenavigationmenus.2)Gridexcelsintwo-dimensional,complexdesignssuchasmagazinelayouts.3)Combiningbothenhanceslayoutflexibilityandresponsiveness,allowingforstructur


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version
Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools
