The transform and transition in CSS

Source: Internet
Author: User

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:

Rotate ()

The element rotates the given angle clockwise. Negative values are allowed, and the elements rotate counterclockwise.

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:rotate (20deg);            -moz-transform:rotate (20deg);            -ms-transform:rotate (20deg);            -o-transform:rotate (20deg);            Transform:rotate (20deg);        }

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, 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);/* Flips elements around the X-axis 20 degrees, flips 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;/* length is 2s width change effect */            -moz-transition:width 2s;            -o-transition:width 2s;            transition:width 2s;        } div:hover{            width:300px;        }

The transform and transition in CSS

Related Article

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.