First HTML a parent div contains four absolutely positioned DIV
- <div class=' container container--realistic '>
- <div class=' cube cube--ani '>
- <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);
- }
Let the cube spin.
- . Cube--ani {
- -webkit-animation:rot 4s linear infinite;
- }
- @-webkit-keyframes Rot {
- to {-webkit-transform:rotatey (-330deg) Rotatex (370deg);}
- }
This defines an animated rot.
From the starting position to the y-axis -330deg x-axis 370deg
and Loop unlimited times, 4s each time
Ok!
CSS3 realizes the cube, and the rotation effect