“` @keyframes 动画名称 { 动画状态 }
:代码展示如下 div{ width:200px; height:200px; background-color: lightblue; margin:150px auto; } @keyframes domove { 0%{width:200px;} 33%{width:300px;} 66%{width:600px;} 100%{width:1000px;} } div:hover{ animation: domove 3s linear forwards; }#div1{ width: 1000px; height:30px; border: #cccccc solid 1px; margin: 200px auto; border-radius: 15px; } #div1 div{ width: 0; height:30px; background-color: slategray; border-radius: 15px; animation: domove 4s linear forwards; } #div1:hover div{ animation-play-state:paused; } @keyframes domove { 0%{width:0;} 50%{width:800px;} 100%{width: 1000px;} }