在CSS中使用(?m)
可以得到动画,其中属性在@keyframes
上逐渐变化。但是我想要立即更改属性。这样一来,标记在0%到25%的整个属性中都会变成一个,然后立即变化,而不是逐渐变化。我该怎么办?
答案 0 :(得分:0)
.move-me {
display: inline-block;
padding: 20px;
color: white;
position: relative;
margin: 0 0 10px 0;
}
.move-me-1 {
animation: move-in-steps 8s steps(4) infinite;
}
.move-me-2 {
animation: move-in-steps 8s steps(4, start) infinite;
}
.move-me-3 {
animation: move-in-steps 8s infinite;
}
body {
padding: 20px;
}
@keyframes move-in-steps {
0% {
left: 0;
background: blue;
}
100% {
left: 100%;
background: red;
}
}
<div class="move-me move-me-1">steps(4, end)</div>
<br>
<div class="move-me move-me-2">steps(4, start)</div>
<br>
<div class="move-me move-me-3">no steps</div>
您可能需要在CSS动画中使用steps()
我从此页面引用的代码段
https://css-tricks.com/using-multi-step-animations-transitions/