Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use css to realize 3D Image rotation effect

Shulou Source: shulou.com Published: 2022-05-31 13:11:52 10月02日 Update

This article mainly introduces "how to use css to achieve 3D image rotation effect". In daily operation, I believe many people have doubts about how to use css to achieve 3D image rotation effect. Xiaobian 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 doubt of "how to use css to achieve 3D image rotation effect". Next, please follow the editor to study!

First of all, look at the html file, div.billboard is the effect of the container, using 10 div.poster to segment the image, each poster has three face, respectively used to carry three images.

XML/HTML Code copies content to the clipboard

CSS file here we use sass, using scss syntax.

CSS Code copies content to the clipboard

/ / variable initialization / / number of image blocks. If you want to change, html needs to modify $numPoster:10; / / rotate the number of images. If you want to change, html needs to modify $numFace:3; / / Image width $width:600px; / / Image height $height:320px / / the settings of the box .billboard {width:$width; margin:100px auto;} / / the image bar floats to the left. Poster {float:left; width:$width/$numPoster; height:$height } / / uniform setting of image strips, absolute positioning, 3D animation settings. Face {position:absolute; height:$height; width:$width/$numPoster; transform-origin:50% 50-17px; backface-visibility: hidden; transform-style:preserve-3d; perspective:350px } / / set the background image and animate @ for $I from 1 through $numFace {.poster .panel # {$I} {background:url (http://gx.zptc.cn/whqet/img/#{$i}.jpg); transform:transformY (360degapash facial numb * ($I-1)) respectively; animation: rotateMe# {$I} 10s infinite } @ keyframes rotateMe# {$I} {0% {transform:rotateY (360 degdegmax numFacebook * ($I-1));} 9% {transform:rotateY (360 degmax numFacebook * ($I-1));} 24% {transform:rotateY (360 degmax numFacebook * ($I)) } 42% {transform:rotateY (360 degmax numFacebook * ($I));} 57% {transform:rotateY (360 degmax numFacebook * ($I + 1));} 75% {transform:rotateY (360 degmax numFacebook * ($I + 1)) } 90% {transform:rotateY (360 degmax numFacebook * ($I + 2));} 100% {transform:rotateY (360 degmax numFacebook * ($I + 2)) } / / background offset of image strips @ for $I from 1 through $numPoster {.poster .p # {$I} {background-position:- ($width/$numPoster* ($I-1)) top;}} so far, the study on "how to use css to achieve 3D image rotation effect" 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!

Tags: Images effects rotation learning three number content clipboard animation files more background face clip help utility next variables containers width Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Huawei Shulou Information Shulou Technology Microsoft