Detailed explanation of Animation for CSS3 learning
Y2J
Release: 2017-05-20 11:48:07
Original
1710 people have browsed it
CSS3 Animation
There are three properties related to animation in CSS3 properties: Transform, Transition, and Animation; we have finished studying Transform and Transition together, and let us implement some basic animation effects on elements. These I think it was enough to make everyone excited for a while. Today we take advantage of this enthusiasm to continue learning the third animation attribute, Animation. From the literal meaning of Animation, we know that it means "animation". But Animation in CSS3 is different from Canvas drawing animation in HTML5. Animation is only applied to DOM elements that already exist on the page, and it is different from the animation effects produced by Flash, JavaScript and jQuery, because we use CSS3 Animation can save us from complex js and jquery codes when making animations (which is very happy for people like me who don’t understand js). There is just one shortcoming. We can use Animation to create what we want. There are some animation effects, but they are a bit rough. If you want to make better animations, I think you should use flash or js. Although the animation produced by Animation is simple and rough, I think it still cannot reduce our enthusiasm for learning it.
Before we start introducing Animation, we need to understand a special thing first, that is "Keyframes". We call it "keyframes". Friends who have played flash may not be familiar with this thing. Not unfamiliar. Let's take a look at what this "Keyframes" is. When we used transition to create a simple transition effect earlier, we included initial attributes and final attributes, a start action time and a continuation action time as well as the transformation rate of the action. In fact, these values are all intermediate values. If we want The control is more detailed, for example, what actions do I want to perform in the first time period, and what actions do I want to perform in the second time period (switching to flash, it means what actions I want to perform in the first frame, and what actions I want to perform in the second frame What action), it is difficult for us to use Transition to achieve this. At this time, we also need such a "key frame" to control. Then CSS3 Animation uses the "keyframes" attribute to achieve this effect. Let's take a look at Keyframes first:
Keyframes have their own syntax rules. Their naming starts with "@keyframes", followed by the "name of the animation" plus a pair of curly braces. "{}", in brackets are some style rules for different time periods, a bit like our CSS style writing. For a style rule in "@keyframes" that is composed of multiple percentages, such as between "0%" and "100%", we can create multiple percentages in this rule, and we give each percentage a Elements with animation effects need to be added with different attributes, so that the elements can achieve a constantly changing effect, such as moving, changing element color, position, size, shape, etc. However, one thing to note is that we can use "fromt" and "to" represent where an animation starts and ends. In other words, "from" is equivalent to "0%" and "to" is equivalent to "100%". It is worth mentioning that, Among them, "0%" cannot omit the percent sign like other attribute values. We must add the percent sign ("%") here. If not, our keyframes will be invalid and will have no effect. Because the unit of keyframes only accepts percentage values.
Keyframes can specify any order to determine the key position of the Animation animation change. The specific grammar rules are as follows:
IDENT is an animation name, you can choose it casually, of courseSemantica little more Okay, Percentage is a percentage value. We can add many such percentages. Properties are css property names, such asleft,background, etc. Value is the attribute of the corresponding property. value. It is worth mentioning that our from and to correspond to 0% and 100% respectively. We have mentioned this before. So far, only browsers with webkit core support animation animation, so I need to add the -webkit prefix to the above. It is said that Firefox5 can support the animation animation property of CSS3.
Let’s take a look at an example ofW3Cofficial website
The above is the detailed content of Detailed explanation of Animation for CSS3 learning. For more information, please follow other related articles on the PHP Chinese website!
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn