Home > Web Front-end > CSS Tutorial > How to use transition-property attribute

How to use transition-property attribute

青灯夜游
Release: 2019-02-01 14:22:57
Original
4296 people have browsed it

The transition-property property is the name of the CSS property used to specify the application of the transition effect; when the specified CSS property changes, the transition effect will start.

How to use transition-property attribute

CSS3 transition-property property

Function: transition-property property Specifies the name of the CSS property to which the transition effect is applied. (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;
Copy after login

none: No attributes will get the transition effect.​

all: All attributes will receive the transition effect.

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

Note: Need to always set the transition-duration attribute, otherwise the duration is 0 and there will be no transition effect.

CSS3 transition-property property usage example

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style> 
div
{
width:100px;
height:100px;
background:red;
margin: 10px 0px;

}
.demo1{
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 */
}
.demo2{
transition-property: height;
transition-duration: 2s;
-moz-transition-property: height; /* Firefox 4 */
-moz-transition-duration: 2s; /* Firefox 4 */
-webkit-transition-property: height; /* Safari and Chrome */
-webkit-transition-duration: 2s; /* Safari and Chrome */
-o-transition-property: height; /* Opera */
-o-transition-duration: 2s; /* Opera */
}
.demo1:hover
{
width:300px;
}
.demo2:hover
{
height:150px;
}
</style>
</head>
<body>
<p>请把鼠标指针移动到红色的 div 元素上,查看过渡效果。</p>
<p>width属性发生变化:</p>
<div class="demo1"></div>
<p>height属性发生变化:</p>
<div class="demo2"></div>
<p><b>注释:</b>本例在 Internet Explorer 中无效。</p>
</body>
</html>
Copy after login

Rendering:

How to use transition-property attribute

The above is the entire content of this article, I hope it will be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template