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

How to realize the 3D rotation effect of pictures by html5

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

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!

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