Css3 achieves cube rotation, and css3 achieves cube Rotation
First, an HTML parent div contains four absolutely positioned Divs.
- <Div class = 'iner iner -- realistic '>
- <Div class = 'CUBE -- wan'>
- <Div class = 'face'> 1 </div>
- <Div class = 'face'> 2 </div>
- <Div class = 'face'> 3 </div>
- <Div class = 'face'> 4 </div>
- </Div>
- </Div>
First, a static cube
- . Face: nth-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 );
- }
Turn the cube
- . 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 the Y axis-330deg X axis 370deg
And the loop is infinite, every 4 s
OK!