Home > Article > Web Front-end > How many transition properties are there in css3?
There are 5: 1. transition-property attribute; 2. transition-duration attribute; 3. transition-timing-function attribute; 4. transition-delay attribute; 5. transition attribute.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
css3 transition allows us to change from one attribute value to another within a limited time.
There are 5 css3 transition attributes:
Attribute | Description | CSS |
---|---|---|
transition | Abbreviation attribute, used to set four transition attributes in one attribute. | 3 |
transition-property | Specifies the name of the CSS property that applies the transition. | 3 |
transition-duration | Define how long the transition effect takes. The default is 0. | 3 |
transition-timing-function | Specifies the time curve of the transition effect. The default is "ease". | 3 |
transition-delay | Specifies when the transition effect starts. The default is 0. | 3 |
Example:
Use all transition properties in one example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> div { width: 100px; height: 100px; background: red; transition-property: width; transition-duration: 1s; transition-timing-function: linear; transition-delay: 2s; /* Safari */ -webkit-transition-property: width; -webkit-transition-duration: 1s; -webkit-transition-timing-function: linear; -webkit-transition-delay: 2s; } div:hover { width: 200px; } </style> </head> <body> <div></div> <p>鼠标移动到 div 元素上,查看过渡效果。</p> <p><b>注意:</b> 过渡效果需要等待两秒后才开始。</p> </body> </html>
The same transition effect as the above example, but using the abbreviated transition attribute:
There are so many transition codes in div{} in the above example
div { transition-property: width; transition-duration: 1s; transition-timing-function: linear; transition-delay: 2s; /* Safari */ -webkit-transition-property:width; -webkit-transition-duration:1s; -webkit-transition-timing-function:linear; -webkit-transition-delay:2s; }
In fact, you only need to use the abbreviated transition attribute and use two lines of code to do it:
div { transition: width 1s linear 2s; /* Safari */ -webkit-transition:width 1s linear 2s; }
(Learning video sharing: css video tutorial)
The above is the detailed content of How many transition properties are there in css3?. For more information, please follow other related articles on the PHP Chinese website!