CSS3 realizes the cube, and the rotation effect

Source: Internet
Author: User

First HTML a parent div contains four absolutely positioned DIV

  1. <div class=' container container--realistic '>
  2. <div class=' cube cube--ani '>
  3. <div class=' face '>1</div>
  4. <div class=' face '>2</div>
  5. <div class=' face '>3</div>
  6. <div class=' face '>4</div>
  7. </div>
  8. </div>


First, a static cube

  1. . Face:nth-child (1) {
  2. -webkit-transform: /*rotatey (0deg) */Translatez (2.5em/ * Half the side length, 5em in this case */);
  3. }
  4. . Face:nth-child (2) {
  5. -webkit-transform:rotatey ( 90deg) Translatez (2.5em);
  6. }
  7. . Face:nth-child (3) {
  8. -webkit-transform:rotatey (180deg) Translatez (2.5em);
  9. }
  10. . Face:nth-child (4) {
  11. -webkit-transform:rotatey (270deg) Translatez (2.5em);
  12. }


Let the cube spin.

    1. . Cube--ani {
    2. -webkit-animation:rot 4s linear infinite;
    3. }
    4. @-webkit-keyframes Rot {
    5. to {-webkit-transform:rotatey (-330deg) Rotatex (370deg);}
    6. }


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.