What is the difference between transition and animation in CSS3
The difference between transition and animation in CSS3: 1. CSS transition requires event triggering, but CSS animation does not; 2. CSS transition only has one set (two) of key frames, which set the start and end actions respectively. CSS animation can define multiple keyframes.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
transition transition
Make css changes smoother
Attribute:
Property | Description |
---|---|
transtion-property | Specifies the property of the transition |
transtion-duration | Specify the time required for transition |
transtion-timing-function | Specify the transition function |
transtion-delay | Specify the transition delay time |
Syntax:
transiton: 过渡属性 过渡所需要时间 过渡动画函数 过渡延迟时间; //合在一起
Chestnut:
<style> img{ height:150px; width:150px; transition: height 0.5s linear 0.5s; } img:hover{ height:100px; } </style>
The advantage of transition is that it is simple and easy to use, but it has several major limitations.
- Transition requires event triggering, so it cannot occur automatically when the web page is loaded.
- Transition is a one-time event and cannot occur repeatedly unless triggered again and again.
- Transition can only define the start state and end state, but not the intermediate state.
- A transition rule can only define changes to one attribute and cannot involve multiple attributes.
CSS Animation was proposed to solve these problems.
animation animation
Control each step of the animation by controlling key frames to achieve more complex animation effects
Properties:
Properties | Description |
---|---|
Specify keyframe animation The name | |
Specifies the time required for animation playback, in seconds | |
Specify the animation playback method | |
Specify the animation start time in seconds | |
Specifies the number of times to play the animation, the default is 1, if it is infinite, it will be played in an infinite loop | |
Specify the playback direction of the animation. The default is normal. If it is alternate, it will play in reverse in turn. |
- Declare an animation with key frames
- Call the animation declared with key frames in animation.
- @keyframes are key frames. There can be many frames in an animation.
A style rule in @keyframes is composed of multiple percentages. Multiple percentages can be created on this rule to achieve a constantly changing effect.
Chestnut:
<style> img{ width:90px; height:90px; animation: mychange 1s infinate 1s; -webkit-animation: mychange 1s infinate 1s; } @keyframes mychange{ 0%{width:90px; height:90px; } 50%{width:130px; height:130px;} 100%{width:200px; height:200px;} } @-webkit-keyframes mychange{ 0%{width:90px; height:90px; } 50%{width:130px; height:130px;} 100%{width:200px; height:200px;} } </style>
The percent signs of 0% and 100% in the above code cannot be omitted, 0% can be replaced by from, and 100% can be replaced by to. For the mychange animation to have an effect, it must be called through the CSS3 animation property.
The difference between css transition and animationThe main difference is that transition needs to trigger an event to change its CSS properties over time; Without triggering any events, animation can also explicitly change the CSS properties of elements over time to achieve an animation effect.
1) CSS transition needs to be triggered by an event (like :hover, etc.) to work, but animation does not.
2) The transition has only one set (two: start-end) of key frames, and animation can define multiple key frames.
3) Use transition and animation to create a dynamic effect when the mouse is hovering. When the mouse is moved away, the effect created by transition will slowly change back to its original appearance, while the animation will snap. Change back to your original self.
(Learning video sharing:
css video tutorial, web front-end introductory tutorial)
The above is the detailed content of What is the difference between transition and animation 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

AI Hentai Generator
Generate AI Hentai for free.

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



When Microsoft launched Windows 11, it brought a lot of changes. One of the changes is an increase in the number of user interface animations. Some users want to change the way things appear, and they have to find a way to do it. Having animations makes it feel better and more user-friendly. Animation uses visual effects to make the computer look more attractive and responsive. Some of them include sliding menus after a few seconds or minutes. There are many animations on your computer that can affect PC performance, slow it down, and interfere with your work. In this case you have to turn off animation. This article will introduce several ways that users can improve the speed of their animations on PC. You can apply the changes using Registry Editor or a custom file you run. How to improve animations in Windows 11

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

CSS transition effect: How to achieve the fade-in and fade-out effect of elements Introduction: In web design, making elements have transition effects is one of the important means to improve user experience. The fade-in-fade-out effect is a common and concise transition effect that can make elements appear from scratch, from shallow to deep. This article will introduce how to use CSS to achieve the fade-in and fade-out effect of elements, and give specific code examples. 1. Use the transition attribute to achieve the fade-in and fade-out effect of the element. The transition attribute of CSS can add elements to the element.

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.

Microsoft Windows 11 includes many new features and functions. The user interface has been updated and the company has also introduced some new effects. By default, animation effects are applied to controls and other objects. Should I disable these animations? Although Windows 11 features visually appealing animations and fade effects, they can cause your computer to feel sluggish to some users as they add a bit of lag to certain tasks. It's easy to turn off animations for a more responsive user experience. After we see what other changes have been made to the operating system, we'll walk you through how to turn animation effects on or off in Windows 11. We also have an article on how to
