<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
/*定义动画*/
@keyframes move {
from{
background-color: #a5f5cd;
transform: translate(0px);
}
to{
background-color: #eab9d2;
transform: translate(500px);
}
}
/*盒子*/
div{
width: 100px;
height: 100px;
background-color: #ff0000;
/*动画名*/
animation-name: move;
/*动画持续时间*/
animation-duration: 2s;
/*开始延迟时间*/
animation-delay: .5s;
/*动画运动轨迹 ease缓慢 linear匀速 */
animation-timing-function: ease;
/*运动的方向 reverse 反向 normal正常 alternate奇次正常,偶次反向 alternate-reverse 偶次正常,奇次反向*/
animation-direction: alternate;
/*保留动画格式 forwards保留最后一帧的格式 backwoards保留原格式 both 保留第一帧和最后一帧*/
animation-fill-mode: both;
/*动画执行的次数 infinte 无限次 */
animation-iteration-count: infinite;
}
div:hover{
/*动画状态 paused暂停 runing正常*/
animation-play-state: paused;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
CSS3动画属性总结
最新推荐文章于 2025-08-09 14:20:21 发布