CSS3 @ keyframes animation, css3 @ keyframes

Source: Internet
Author: User

CSS3 @ keyframes animation, css3 @ keyframes

@ Keyframes of CSS3, which can replace many webpage animated images, Flash animations, and JAVAScripts.

Animation attributes of CSS3

The following table lists the @ keyframes rules and all animation attributes:

Browser support

The number in the table indicates the first browser version that supports this attribute.

The number that follows "-webkit-", "-ms-", or "-moz-" is the first browser version that supports this prefix attribute.

Example:

@ Keyframes myfirst {from {background: red;} to {background: yellow; }}@-webkit-keyframes myfirst/* Safari and Chrome */{from {background: red ;} to {background: yellow ;}}

 

When@ KeyframesCreate an animation and bind it to a selector. Otherwise, the animation will not have any effect.

Specify at least two CSS3 animation attributes to bind to a selector:

  • Specifies the animation name
  • Specifies the animation duration

For example:

Div {animation: myfirst 5S;-webkit-animation: myfirst 5S;/* Safari with Chrome */}

 Note:You must define the animation name and duration. If the duration is omitted, the animation cannot run because the default value is 0.

 

Instance:Note:This instance is invalid in Internet Explorer 9 and earlier IE versions.

div{    width:100px;    height:100px;    background:red;    position:relative;    animation-name:myfirst;    animation-duration:5s;    animation-timing-function:linear;    animation-delay:2s;    animation-iteration-count:infinite;    animation-direction:alternate;    animation-play-state:running;    /* Safari and Chrome: */    -webkit-animation-name:myfirst;    -webkit-animation-duration:5s;    -webkit-animation-timing-function:linear;    -webkit-animation-delay:2s;    -webkit-animation-iteration-count:infinite;    -webkit-animation-direction:alternate;    -webkit-animation-play-state:running;}@keyframes myfirst{    0%   {background:red; left:0px; top:0px;}    25%  {background:yellow; left:200px; top:0px;}    50%  {background:blue; left:200px; top:200px;}    75%  {background:green; left:0px; top:200px;}    100% {background:red; left:0px; top:0px;}}@-webkit-keyframes myfirst /* Safari and Chrome */{    0%   {background:red; left:0px; top:0px;}    25%  {background:yellow; left:200px; top:0px;}    50%  {background:blue; left:200px; top:200px;}    75%  {background:green; left:0px; top:200px;}    100% {background:red; left:0px; top:0px;}}

 

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.