How to realize the 3D rotation effect of pictures by html5
This article mainly explains "how to achieve the 3D rotation effect of the picture by html5". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to achieve the 3D rotation effect of the picture by html5".
The complete code is as follows:
HTML5 3D rotates the picture album but hovers over the mouse
* {
Padding: 0
Margin: 0
Border: none
Outline: none
Box-sizing: border-box
}
*: before,*:after {
Box-sizing: border-box
}
Html,body {
Min-height: 100%
}
Body {
Background-image: radial-gradient (mintcream 0%, lightgray 100%)
}
.Container {
Margin: 4% auto
Width: 210px
Height: 140px
Position: relative
Perspective: 1000px
}
# carousel {
Width: 100%
Height: 100%
Position: absolute
Transform-style:preserve-3d
Animation: rotation 20s infinite linear
}
# carousel:hover {
Animation-play-state: paused
}
# carousel figure {
Display: block
Position: absolute
Width: 220px
Height: 120px
Left: 10px
Top: 10px
Background: black
Overflow: hidden
Border: solid 5px black
}
Img {
Filter: grayscale (1)
Cursor: pointer
Transition:all 0.3s ease 0s
Width: 100%
Height: 100%
}
Img:hover {
Filter: grayscale (0)
Transform: scale (1.2)
}
# carousel figure:nth-child (1) {transform: rotateY (0deg) translateZ (288px);}
# carousel figure:nth-child (2) {transform: rotateY (60deg) translateZ (288px);}
# carousel figure:nth-child (3) {transform: rotateY (120deg) translateZ (288px);}
# carousel figure:nth-child (4) {transform: rotateY (180deg) translateZ (288px);}
# carousel figure:nth-child (5) {transform: rotateY (240deg) translateZ (288px);}
# carousel figure:nth-child (6) {transform: rotateY (300deg) translateZ (288px);}
@ keyframes rotation {
From {
Transform: rotateY (0deg)
}
To {
Transform: rotateY (360deg)
}
}
At this point, I believe you have a deeper understanding of "how to achieve the 3D rotation effect of the picture by html5". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!