Home>Article>Web Front-end> How to achieve animation effect of changing width in css3
Method: 1. Use the "element {animation: name time}" statement to bind animation to the element; 2. Use the "@keyframes name {100%{width: width value;}}" statement to set the element The animation action of changing the width realizes the animation effect of the element changing the width.
The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.
How to achieve the animation effect of changing the width of css3
In css, you can use the animation attribute and @keyframes rule to change the width of the element Animation effects, through @keyframes rules, can create animations.
The principle of creating animation is to gradually change one set of CSS styles into another set of styles. You can change this set of CSS styles multiple times during the animation.
Specify the time when the change occurs as a percentage, or through the keywords "from" and "to", which are equivalent to 0% and 100%. 0% is the start time of the animation, 100% is the end time of the animation. For best browser support, you should always define 0% and 100% selectors.
Use the width attribute to set the animation action. This property is used to set the width of the element.
The syntax format of the animation attribute is as follows:
animation: name duration timing-function delay iteration-count direction;
The example is as follows:
Document
Output result:
(Learn Video sharing:css video tutorial)
The above is the detailed content of How to achieve animation effect of changing width in css3. For more information, please follow other related articles on the PHP Chinese website!