css transition property is a shorthand property, its syntax is transition: property duration timing-function delay, used to set four transition properties.
#How to use the css transition attribute?
Function:
The transition property is an abbreviated property used to set four transition properties: transition-property transition-duration transition-timing-function transition -delay
Syntax:
transition: property duration timing-function delay;
Description:
transition-property Specifies the name of the CSS property that sets the transition effect.
transition-duration Specifies how many seconds or milliseconds it takes to complete the transition effect.
transition-timing-function Specifies the speed curve of the speed effect.
transition-delay Defines when the transition effect starts.
Note: Please always set the transition-duration attribute, otherwise the duration is 0 and no transition effect will occur.
css transition attribute usage example
<!DOCTYPE html> <html> <head> <style> div { width:100px; height:100px; background:blue; transition:width 2s; -moz-transition:width 2s; /* Firefox 4 */ -webkit-transition:width 2s; /* Safari and Chrome */ -o-transition:width 2s; /* Opera */ } div:hover { width:300px; } </style> </head> <body> <div></div> <p>请把鼠标指针移动到蓝色的 div 元素上,就可以看到过渡效果。</p> <p><b>注释:</b>本例在 Internet Explorer 中无效。</p> </body> </html>
Effect output:
The above is the detailed content of How to use css transition attribute. For more information, please follow other related articles on the PHP Chinese website!