Home > Web Front-end > HTML Tutorial > css3 implements cube and rotation effect_html/css_WEB-ITnose

css3 implements cube and rotation effect_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:07:39
Original
1031 people have browsed it

First, HTML. A parent div contains four absolutely positioned divs

4
                                                       -child(1) { -webkit-transform: /*rotateY(0deg)*/ translateZ(2.5em /* half the side length, 5em in this case */); } .face:nth-child(2) { - webkit-transform: rotateY(90deg) translateZ(2.5em); } .face:nth-child(3) { -webkit-transform: rotateY(180deg) translateZ(2.5em); } .face:nth-child(4) { -webkit-transform: rotateY(270deg) translateZ(2.5em); }


Let the cube rotate

.cube--ani { -webkit-animation: rot 4s linear infinite; } @-webkit-keyframes rot { to { -webkit-transform: rotateY(-330deg) rotateX(370deg); } }


An animation rot

is defined here

Rotate from the starting position to Y-axis -330deg X-axis 370deg

And loop infinite times, 4s each time

OK!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template