


Analysis on the differences between animation attributes transform, transition and animation attributes in CSS3
This article mainly introduces the analysis of the differences between the animation properties transform and transition and animation properties in CSS3. It has a certain reference value. Now I share it with you. Friends in need can refer to it
Recently in The animation properties in CSS3 are used in the project. Unfortunately, I am not very familiar with several newly added properties of CSS3, and it is often easy to get confused. So I researched some information from the website and summarized it so that friends in need can refer to it and learn.
Transform
In some test cases, whenever the transform attribute is demonstrated, it seems to be animated. This makes a small number of intuitive thinkers (including me) think that the transform property is an animation property. On the contrary, the transform attribute is a static attribute. Once written into the style, its effect will be displayed directly without any change process. The main purpose of transform is to make special deformations of elements, which is not unfamiliar to designers. Simply put, it is a CSS graphic deformation tool.
Regarding the origin setting among the basic conditions of graphics deformation, transform-origin is used to define it in CSS. The origin of this definition should be calculated from the upper left corner of the element affected by the css as 0,0 (to be studied). Other attributes are calculated based on this attribute.
Regarding the graphic change mode, transform-style is defined in the CSS3 standard. The default is flat, which displays a simple effect. And preserve-3d renders the space in 3D mode. From normal thinking, you should only need preserve-3d, but judging from the rumor that "GPU acceleration is used when preserve-3d is turned on", this attribute may be used to reduce system consumption. After all, 3d is better than 2d. It requires one more dimension of calculation.
If you need to use 3d mode, you must first specify the style as 3d, and add perspective and perspective-origin to any parent element to specify the perspective point.
There are five specific attributes used by designers to change element styles:
1. translate3d(x,y,z) is used to control the position of elements on the page. The position of the three axes;
2. rotate(deg) is used to control the rotation angle of the element;
3. skew[x,y](deg) This attribute is used to create the tilt. It has been done Designers may know that this is a necessary attribute when creating a 3D perspective in 2D;
4. scale3d (x, y, z) is used to enlarge and reduce the effect, and the attribute is the ratio;
5. matrix3d, css matrix. Through this matrix attribute, all the above attribute values are covered, but I personally feel that the readability is extremely poor (it is all numbers and units, which is a bit blurry to memorize), and there is currently no reason to recommend its use.
Generally speaking, there is no difference between the properties of css transform and the originally used left, right, top, and bottom properties from a static and dynamic perspective. Therefore, transform should be classified into this type of positioning deformation when used. Inside the static properties.
Transition
The transition property is a simple animation property, very simple and easy to use. It can be said that it is a simplified version of animation, which is generally used for simple web page special effects. For example, you have the following two styles:
1 2 3 4 5 6 7 8 9 |
|
The transition attribute of animate means: when your left attribute changes, perform animation effects (only based on left attribute changes, other The attributes will not be added to the animation changes);
First of all, the css of your element is position. When you add animate to its cssList or replace position with animate, the attribute of the element changes and webkit-transition is triggered. The value before the specified attribute changes is the starting value, and the attribute after the change is the end value, and the animation effect is executed. This is a simple two-point change process, which greatly simplifies the complexity of the animation attribute.
At the same time, if there is a new change in the attribute value during the transition animation, the current animation execution will be interrupted, and the attribute value at the time of interruption will be provided to the new animation as the starting value to calculate the new animation. animation effect.
When I was writing CSS, because the only changing attribute was transform, I specified the response attribute as all in the transition attribute, which can respond to and execute the change animation of all attributes of the element (attributes that can be animated).
Animation
Introduced in the official Introduction, this attribute is an extension of the transition attribute. But this simple introduction contains something not simple: keyframes.
Anyone who has done Flash animation will know that there are two basic weapons in Flash: timeline and key frames. The emergence of css keyframes provides a collection of these two attributes in the flash world. Look at an example of simple keyframes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
上面这个代码展示了一个keyframes 'wobble',其中 0% 代表在变化中不同时间点的属性值,你可以较精确的控制动画变化中任何一个时间点的属性效果。而animation则根据这个keyframes提供的属性变化方式去计算元素动画当中的属性。与 transition 不同的是,keyframes提供更多的控制,尤其是时间轴的控制,这点让css animation更加强大,使得flash的部分动画效果可以由css直接控制完成,而这一切,仅仅只需要几行代码,也因此诞生了大量(比起flash来说算是大量了)基于css的animation tools,用来取代flash的动画部分。关于动画工具,可以参考Web standards-based Animation Tools.
另外在animation属性里面还有一个最重要的就是:animation-fill-mode,这个属性标示是以(from/0%)指定的样式 还是以(to/100%)指定的样式为动画完成之后的样式。这个很方便我们控制动画的结尾样式,保证动画的整体连贯。
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:
The above is the detailed content of Analysis on the differences between animation attributes transform, transition and animation attributes in CSS3. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



CSS animation: How to achieve the flash effect of elements, specific code examples are needed. In web design, animation effects can sometimes bring a good user experience to the page. The glitter effect is a common animation effect that can make elements more eye-catching. The following will introduce how to use CSS to achieve the flash effect of elements. 1. Basic implementation of flash First, we need to use the animation property of CSS to achieve the flash effect. The value of the animation attribute needs to specify the animation name, animation execution time, and animation delay time
![Animation not working in PowerPoint [Fixed]](https://img.php.cn/upload/article/000/887/227/170831232982910.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
Are you trying to create a presentation but can't add animation? If animations are not working in PowerPoint on your Windows PC, then this article will help you. This is a common problem that many people complain about. For example, animations may stop working during presentations in Microsoft Teams or during screen recordings. In this guide, we will explore various troubleshooting techniques to help you fix animations not working in PowerPoint on Windows. Why aren't my PowerPoint animations working? We have noticed that some possible reasons that may cause the animation in PowerPoint not working issue on Windows are as follows: Due to personal

How to use CSS to implement rotating background image animation effects of elements. Background image animation effects can increase the visual appeal and user experience of web pages. This article will introduce how to use CSS to achieve the rotating background animation effect of elements, and provide specific code examples. First, we need to prepare a background image, which can be any picture you like, such as a picture of the sun or an electric fan. Save the image and name it "bg.png". Next, create an HTML file and add a div element in the file, setting it to

We often use ppt in our daily work, so are you familiar with every operating function in ppt? For example: How to set animation effects in ppt, how to set switching effects, and what is the effect duration of each animation? Can each slide play automatically, enter and then exit the ppt animation, etc. In this issue, I will first share with you the specific steps of entering and then exiting the ppt animation. It is below. Friends, come and take a look. Look! 1. First, we open ppt on the computer, click outside the text box to select the text box (as shown in the red circle in the figure below). 2. Then, click [Animation] in the menu bar and select the [Erase] effect (as shown in the red circle in the figure). 3. Next, click [

How to use Vue to implement typewriter animation special effects Typewriter animation is a common and eye-catching special effect that is often used in website titles, slogans and other text displays. In Vue, we can achieve typewriter animation effects by using Vue custom instructions. This article will introduce in detail how to use Vue to achieve this special effect and provide specific code examples. Step 1: Create a Vue project First, we need to create a Vue project. You can use VueCLI to quickly create a new Vue project, or manually

This website reported on January 26 that the domestic 3D animated film "Er Lang Shen: The Deep Sea Dragon" released a set of latest stills and officially announced that it will be released on July 13. It is understood that "Er Lang Shen: The Deep Sea Dragon" is produced by Mihuxing (Beijing) Animation Co., Ltd., Horgos Zhonghe Qiancheng Film Co., Ltd., Zhejiang Hengdian Film Co., Ltd., Zhejiang Gongying Film Co., Ltd., Chengdu The animated film produced by Tianhuo Technology Co., Ltd. and Huawen Image (Beijing) Film Co., Ltd. and directed by Wang Jun was originally scheduled to be released in mainland China on July 22, 2022. Synopsis of the plot of this site: After the Battle of the Conferred Gods, Jiang Ziya took the "Conferred Gods List" to divide the gods, and then the Conferred Gods List was sealed by the Heavenly Court under the deep sea of Kyushu Secret Realm. In fact, in addition to conferring divine positions, there are also many powerful evil spirits sealed in the Conferred Gods List.

According to news from this site, Miyazaki Hayao's animated film "Porco Rosso" has announced that it will extend the release date to January 16, 2024. This site previously reported that "Porco Rosso" has been launched in the National Art Federation Special Line Cinema on November 17, with a cumulative box office of over 2,000 10,000, with a Douban score of 8.6, and 85.8% of 4 and 5 star reviews. "Porco Rosso" was produced by Studio Ghibli and directed by Hayao Miyazaki. Moriyama Moriyama, Tokiko Kato, Otsuka Akio, Okamura Akemi and others participated in the dubbing. It was originally released in Japan in 1992. The film is adapted from Hayao Miyazaki's comic book "The Age of Airships" and tells the story of the Italian Air Force's ace pilot Pollock Rosen who was magically turned into a pig. After that, he became a bounty hunter, fighting against air robbers and protecting those around him. Plot synopsis: Rosen is a soldier in World War I

The final trailer for Netflix's claymation film "Chicken Run 2" has been released. The film is expected to be released on December 15. This site noticed that the trailer for "Chicken Run 2" shows Chicken Loki and King Kong. Jay launches an operation to find his daughter Molly. Molly is taken away by a truck at FunLand Farm, and Rocky and Ginger risk their lives to retrieve their daughter. The film is directed by Sam Fehr and stars Sandy Way Newton, Zachary Levi, Bella Ramsey, Imelda Staunton and David Bradley. It is understood that "Chicken Run 2" is the sequel to "Chicken Run" after more than 20 years. The first work was released in China on January 2, 2001. It tells the story of a group of chickens who face the fate of being turned into chicken pies in a chicken factory.
