Home  >  Article  >  Web Front-end  >  How to use css transition-property attribute

How to use css transition-property attribute

藏色散人
藏色散人Original
2019-05-29 14:51:243524browse

css The transition-property attribute is used to specify the name of the CSS property that applies the transition effect. Its syntax is transition-property: none|all|property; the transition effect usually occurs when the user floats the mouse pointer over the element.

How to use css transition-property attribute

#How to use the css transition-property attribute?

Function: The transition-property attribute specifies the name of the CSS property that applies the transition effect. (The transition effect will start when the specified CSS property changes). Tip: Transition effects usually occur when the user floats the mouse pointer over an element.

Syntax:

transition-property: none|all|property;

Description:

none No attributes will get the transition effect.​

all ​ All properties will receive the transition effect.​

property ​ Defines a list of CSS property names that apply transition effects. The list is separated by commas.

Note: Please always set the transition-duration attribute, otherwise the duration is 0 and no transition effect will be produced.

css transition-property attribute usage example

<!DOCTYPE html>
<html>
<head>
<style> 
div
{
width:100px;
height:100px;
background:blue;
transition-property: width;
transition-duration: 2s;
-moz-transition-property: width; /* Firefox 4 */
-moz-transition-duration: 2s; /* Firefox 4 */
-webkit-transition-property: width; /* Safari and Chrome */
-webkit-transition-duration: 2s; /* Safari and Chrome */
-o-transition-property: width; /* Opera */
-o-transition-duration: 2s; /* Opera */
}
div:hover
{
width:300px;
}
</style>
</head>
<body>
<div></div>
<p>请把鼠标指针移动到蓝色的 div 元素上,就可以看到过渡效果。</p>
<p><b>注释:</b>本例在 Internet Explorer 中无效。</p>
</body>
</html>

Effect output:

How to use css transition-property attribute

How to use css transition-property attribute

The above is the detailed content of How to use css transition-property attribute. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn