css动画效果之transition(动画效果属性)

时间:2023-03-09 22:11:43
css动画效果之transition(动画效果属性)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<!-- animation:动画效果属性 “关键帧”(@keyframes),它的样式规则是由多个百分比构成的,比如“0%”到“100%”之间,加上不同的属性,从而让元素达到一种不断变化的效果。语法规则如下: @keyframes 动画名称{
0%{元素状态}
...
100%{元素状态}
} animation属性:
animation-name:@keyframes动画的名称
animation-duration:动画完成一个周期所花费的时间,默认是0
animation-timing-function:动画的速度曲线(缓动效果)。默认是“ease”
animation-delay:动画开始的延迟时间,默认是0
animation-iteration-count:动画被播放的次数。默认是1
animation-direction:动画是否在下一周期逆向的播放。默认是“normal”
animation-play-state:动画是否存在运行或暂停,默认是“running”
animation-fill-mode:对象动画时间之外的状态
-->
<style>
.box{
height: 100px;
width: 100px;
margin:50px auto;
background-color: #f00
}
.box:hover{
/* 绑定动画名称,设置完成周期1s,设置速度曲线加速,设置延迟时间0,设置播放次数无限,循环逆向播放*/
animation: hover 1s ease-in 0s infinite alternate;
}
@keyframes hover{
0%{width: 100px;height: 100px;border-radius: 50%;}
50%{width: 200px;height: 200px;border-radius: 50%;}
100%{width: 100px;height: 100px;border-radius: 50%;}
}
</style> }
<style> </style>
<body>
<div class="box"></div>
</body>
</html>

Document


}