"Reprint" CSS3 commonly used four animation (rotate, enlarge, rotate enlarge, move)

Source: Internet
Author: User
CSS3 Four animations (rotate, enlarge, rotate, enlarge, move)

In the page design, to some of the icons or pictures to add some animation effect, it will give a very comfortable feeling. Four commonly used animation effects are collected here for unexpected contingencies. Reprint the original text

effect One: 360° rotation modified rotate (rotation degree)

* {
    transition:all 0.4s ease-in-out;
    -webkit-transition:all 0.4s ease-in-out;
    -moz-transition:all 0.4s ease-in-out;
    -o-transition:all 0.4s ease-in-out;
}
*:hover {
    transform:rotate (360deg);
    -webkit-transform:rotate (360deg);
    -moz-transform:rotate (360deg);
    -o-transform:rotate (360deg);
    -ms-transform:rotate (360deg);
}

effect Two: Enlarge and modify scale (enlarged value)

* {
    transition:all 0.4s ease-in-out;
    -webkit-transition:all 0.4s ease-in-out;
    -moz-transition:all 0.4s ease-in-out;
    -o-transition:all 0.4s ease-in-out;
}
*:hover {
    Transform:scale (1.2);
    -webkit-transform:scale (1.2);
    -moz-transform:scale (1.2);
    -o-transform:scale (1.2);
    -ms-transform:scale (1.2);
}

effect Three: Rotate enlarge modify rotate (rotate degree) scale (enlarge value)

* {
    transition:all 0.4s ease-in-out;
    -webkit-transition:all 0.4s ease-in-out;
    -moz-transition:all 0.4s ease-in-out;
    -o-transition:all 0.4s ease-in-out;
}
*:hover {
    transform:rotate (360deg) scale (1.2);
    -webkit-transform:rotate (360DEG) scale (1.2);
    -moz-transform:rotate (360DEG) scale (1.2);
    -o-transform:rotate (360DEG) scale (1.2);
    -ms-transform:rotate (360DEG) scale (1.2);
}

effect four: up and down move modify translate (x axis, Y axis)

* {
    transition:all 0.4s ease-in-out;
    -webkit-transition:all 0.4s ease-in-out;
    -moz-transition:all 0.4s ease-in-out;
    -o-transition:all 0.4s ease-in-out;
}
*:hover {
    transform:translate (0,-10px);
    -webkit-transform:translate (0,-10px);
    -moz-transform:translate (0,-10px);
    -o-transform:translate (0,-10px);
    -ms-transform:translate (0,-10px);
}

Reprint Original Address: http://www.jq-school.com/Show.aspx?id=281

Under for my supplementary scss makeover

Such code is bad for our work. Here I highly recommend that you use Scss to write CSS styles.

Perform animation and execution time setting @mixin dz ($time: 0.25s) {-webkit-transition:all $time ease-in-out;
    -moz-transition:all $time ease-in-out;
    -o-transition:all $time ease-in-out;
    -ms-transition:all $time ease-in-out;
Transition:all $time ease-in-out;
    //Propaganda animation call @mixin XZ ($deg: 360) {transform:rotate ($deg +deg);
    -webkit-transform:rotate ($deg +deg);
    -moz-transform:rotate ($deg +deg);
    -o-transform:rotate ($deg +deg);
-ms-transform:rotate ($deg +deg);
    }//Enlarge animation @minxin FD ($s 1:1.2) {Transform:scale ($s 1);
    -webkit-transform:scale ($s 1);
    -moz-transform:scale ($s 1);
    -o-transform:scale ($s 1);
-ms-transform:scale ($s 1);
    }//Rotate Amplification Animation @mixin xzfd ($deg: 360, $s 1:1.2) {transform:rotate ($deg +deg) scale ($s 1);
    -webkit-transform:rotate ($deg +deg) scale ($s 1);
    -moz-transform:rotate ($deg +deg) scale ($s 1);
    -o-transform:rotate ($deg +deg) scale ($s 1);
-ms-transform:rotate ($deg +deg) scale ($s 1);
    }//Mobile animation @mixin yd ($s 1:0, $s 2:0) {transform:translate ($s 1, $s 2); -Webkit-transform:translate ($s 1, $s 2);
    -moz-transform:translate ($s 1, $s 2);
    -o-transform:translate ($s 1, $s 2);
-ms-transform:translate ($s 1, $s 2);  }

How to use

#somebox {
    @include dz ();
    &:hover {
        @include yd ( -10px,-10px);
    }
}

More Scss use method, please Baidu "SASS"

SASS is a pure indent with no curly braces, which is not good for the front end personnel. Therefore, the introduction of the curly bracket version of the SCSS is consistent with the syntax. Just there's no difference between curly braces. In our work, we generally use scss to write CSS, but when looking for scss problem, general search Sass

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.