Introduction of transitions function of CSS3 animation function

Source: Internet
Author: User

In CSS3, if you use the animation feature, you can animate the text or portrait on the page so that the background color is smoothed from one color to another.

The animation function in CSS3 is divided into transition function and animations function, both of which can be animated by changing the value of the property in CSS.
So far, the transitions feature supports smoothing over from one property value to another, and the animations feature enables more complex animation on the page through the designation of keyframes.

Transitions function

Browser Firefox 4+ Opera Ten Safari 3.1+ Chrome 8+
Each browser's wording -moz-transition -o-transition -webkit-transition -webkit-transition
Transition:property Duration Timing-function;property represents a smooth transition to which property, duration indicates how long it takes to complete a smooth transition of the property Timing-function means how to smooth the transition;

Html:

<p> Sample Text </p>

Smooth transition CSS For a property value:

Online demo (mouse over, background color change)

<style>      p {        background-color:pink;        -webkit-transition:background-color 1s linear;        -moz-transition:background-color 1s linear;        -o-transition:background-color 1s linear;      }      p:hover {        background-color:blue;  /* Mouse over background color change */          }</style>

CSS that smoothly transitions multiple property values:

Online demo (mouse over, background color, font color, width change)

<style>      p {        background-color:pink;        -webkit-transition:background-color 1s linear,color 1s linear,width 1s linear;        -moz-transition:background-color 1s linear,color 1s linear,width 1s linear;        -o-transition:background-color 1s linear,color 1s linear,width 1s linear;      }      p:hover {        background-color:blue;/* Mouse changed background color *           /color: #fff;  /* Mouse through Font color change */           width:400px;  /* Mouse Width changed */         }</style>

Online demo (integrated with Transitions animation):

Mouse through the picture, first move to the right 30px, and then rotated 180 degrees;

Html:

<p></p>

Css:

  img {        position:absolute;      top:70px;      left:0;      -webkit-transform:rotate (0deg);      -webkit-transitions:left 1s linear,-webkit-transform 1s linear;      -moz-transform:rotate (0deg);      -moz-transitions:left 1s linear,-moz-transform 1s linear;      -o-transform:rotate (0deg);      -o-transitions:left 1s linear,-o-transform 1s linear;    }    P:hover img{      Position:absolute;      left:30px;      -webkit-transform:rotate (180deg);      -moz-transform:rotate (180deg);      -o-transform:rotate (180deg);    }

Analytical:
The disadvantage of animating with the Transitions feature is that you can specify only the start and end values of a property, and then smooth transitions between the two properties, which do not achieve more complex animation effects;
However, animating with the animation feature allows for complex animation effects on the page through the designation of keyframes.

In CSS3, if you use the animation feature, you can animate the text or portrait on the page so that the background color is smoothed from one color to another.
The animation function in CSS3 is divided into transition function and animations function, both of which can be animated by changing the value of the property in CSS.
So far, the transitions feature supports smoothing over from one property value to another, and the animations feature enables more complex animation on the page through the designation of keyframes.

Transitions function

Browser Firefox 4+ Opera Ten Safari 3.1+ Chrome 8+
Each browser's wording -moz-transition -o-transition -webkit-transition -webkit-transition
Transition:property Duration Timing-function;property represents a smooth transition to which property, duration indicates how long it takes to complete a smooth transition of the property Timing-function means how to smooth the transition;

Html:

<p> Sample Text </p>

Smooth transition CSS For a property value:

Online demo (mouse over, background color change)

<style>      p {        background-color:pink;        -webkit-transition:background-color 1s linear;        -moz-transition:background-color 1s linear;        -o-transition:background-color 1s linear;      }      p:hover {        background-color:blue;  /* Mouse over background color change */          }</style>

CSS that smoothly transitions multiple property values:

Online demo (mouse over, background color, font color, width change)

<style>      p {        background-color:pink;        -webkit-transition:background-color 1s linear,color 1s linear,width 1s linear;        -moz-transition:background-color 1s linear,color 1s linear,width 1s linear;        -o-transition:background-color 1s linear,color 1s linear,width 1s linear;      }      p:hover {        background-color:blue;/* Mouse changed background color *           /color: #fff;  /* Mouse through Font color change */           width:400px;  /* Mouse Width changed */         }</style>

Online demo (integrated with Transitions animation):

Mouse through the picture, first move to the right 30px, and then rotated 180 degrees;

Html:

<p></p>

Css:

  img {      position:absolute;      top:70px;      left:0;      -webkit-transform:rotate (0deg);      -webkit-transitions:left 1s linear,-webkit-transform 1s linear;      -moz-transform:rotate (0deg);      -moz-transitions:left 1s linear,-moz-transform 1s linear;      -o-transform:rotate (0deg);      -o-transitions:left 1s linear,-o-transform 1s linear;    }    P:hover img{      Position:absolute;      left:30px;      -webkit-transform:rotate (180deg);      -moz-transform:rotate (180deg);      -o-transform:rotate (180deg);    }

Parsing:
The disadvantage of animating with the Transitions feature is that you can specify only the start and end values of a property, and then smooth transitions between the two properties without a more complex animation effect;
But animate with the animation feature, It allows for complex animation effects on the page through the designation of keyframes.

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.