CSS3 timing-function:steps () Introduction

Source: Internet
Author: User

When applying CSS3 gradients/animations, there is a control time property of <timing-function>. There is a steps () function in addition to the three-time Bezier curve that is commonly used in its value.

The steps function specifies a step function, the first parameter specifies the number of intervals in the time function (must be a positive integer), the second argument is optional, accepts the start and end two values, specifies that the step change occurs at the beginning or end of each interval, and the default is end.

 #demo  {animation-iteration-count :  2 ;//animation repeats two times    animation-duration :  3  s;//each animation duration is 3s   }    

We apply steps (3, start) and steps (3, end) respectively to it, making the step function curve as follows:

1. Take steps (3, start)

The first parameter divides the animation into three parts. The second argument, "Start", specifies that a step change occurs at the beginning of each section, which is the solid circle in the figure. The process of animation is: 1/3 state →2/3 state → last state.

Here's a simple demo that turns a box from red to white in 5 steps. In this demo you can see that the final status is white: Http://runjs.cn/detail/mqbdpite

2. Take steps (3, end)

Unlike steps (3, start), the process of animation is: State →2/3 state when the initial state →1/3. This means that the final state of the definition is not displayed, but rather shows the state of the 1/3 time period before the end. We also observe by demo: Http://runjs.cn/detail/77frfllv. The same is changed from red to white, but the final state is not white.

The demo in the attachment is an animation that combines "Sprite graph" (see link http://km.oa.com/group/23033/articles/show/226032) and steps () to achieve a little boy running.

 @keyframes animate  {to  {background-position  : -3420  px;     }.kai  .animate  {animation :  animate 0.75  s steps (19 )  Infinite;   }   

The full effect of the animation is to take the picture in 0.75s, divided 19 times (Sprite chart just has a little boy 19 action), horizontal direction to the left to move 3420px (image width).

Go to the attachment and let your boy run.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

CSS3 timing-function:steps () Introduction

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.