The transform and transition of CSS learning

Source: Internet
Author: User

In front-end development, we often use CSS in the transform and transition, then what are their specific usage? Share with you today one or two.

Transform: Conversion

Moves, scales, rotates, lengthens, or stretches an element.

Method: Translate ():

Element is moved from its current position, based on the given left (x-coordinate) and top (y-coordinate) positional parameters

There are two div's, and their CSS style is as follows:

. before {

width:70px;

height:70px;

Background-color: #8fbc8f;

}

. After {

width:70px;

height:70px;

Background-color: #ffe4c4;

-webkit-transform:translate (50px, 30px);

-moz-transform:translate (50px, 30px);

-ms-transform:translate (50px, 30px);

-o-transform:translate (50px, 30px);

Transform:translate (50px, 30px);

}


The results are as follows:

Scale ()

The dimensions of the element are increased or decreased, depending on the given width (X-axis) and height (Y-axis) parameters

There are two div's, and their CSS style is as follows:

. before {

width:70px;

height:70px;

Background-color: #8fbc8f;

}

. After {

width:70px;

height:70px;

Background-color: #ffe4c4;

-webkit-transform:scale (1.5, 0.8);/* The width becomes 1.5 times times the original and the height becomes 0.8 times times the original */

-moz-transform:scale (1.5, 0.8);

-ms-transform:scale (1.5, 0.8);

-o-transform:scale (1.5, 0.8);

Transform:scale (1.5, 0.8);

}


The results are as follows:


Skew ()

The element flips the given angle, according to the given horizontal line (X axis) and vertical (Y-axis) parameters

. before {

width:70px;

height:70px;

Background-color: #8fbc8f;

}

. After {

width:70px;

height:70px;

Background-color: #ffe4c4;

-webkit-transform:skew (20deg, 20deg);/* Flip elements around the X-axis 20 degrees, flip 20 degrees around the Y-axis */

-moz-transform:skew (20deg, 20deg);

-ms-transform:skew (20deg, 20deg);

-o-transform:skew (20deg, 20deg);

Transform:skew (20deg, 20deg);

}


The results are as follows:

Transition: Transition

The effect of an element gradually changing from one style to another

There is a Div, and its CSS style is as follows:

div {

width:100px;

height:100px;

Background-color: #87cefa;

-webkit-transition:width 2s;/* width change effect of 2s */

-moz-transition:width 2s;

-o-transition:width 2s;

Transition:width 2s;

}

div:hover{

width:300px;

}


Article Source: HTML5 China

The transform and transition of CSS learning

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.