CSS3过渡效果及进度条案例
作者:互联网
01-CSS3过渡效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS3过渡效果</title>
<style>
div {
width: 200px;
height: 100px;
background-color: pink;
/* transition: 变化的属性 花费时间 运动曲线 何时开始; 运动曲线和何时开始可以省略*/
/* transition: height .5s ease 1s; */
/* 如果想要写多个属性,可以用逗号分割 */
/* transition: width .5s ease 1s, height .5s ease 1s */
/* 如果要所有的属性都变化,属性可以直接写all */
transition: all .5s
}
div:hover {
width: 400px;
height: 200px;
background-color: skyblue;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
效果展示
02-进度条案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS3过渡练习-进度条</title>
<style>
.bar {
width: 150px;
height: 15px;
border: 1px solid red;
border-radius: 7px;
padding: 1px;
}
.bar_in {
width: 50%;
height: 100%;
background-color: red;
transition: all .7s;
}
/* 意思是鼠标经过父盒子bar时 子盒子.bar_in变宽 */
.bar:hover .bar_in {
width: 100%;
}
</style>
</head>
<body>
<div class="bar">
<div class="bar_in"></div>
</div>
</body>
</html>
效果展示
标签:transition,bar,width,color,进度条,5s,height,案例,CSS 来源: https://blog.csdn.net/WangZhang_521/article/details/122331996