是否可以在关键帧中指定百分比?



例如,我想指定 100%

@keyframes example {
0%   {height: 0px;}
100% {height: 100%;}
}
container {
height: auto; //variable height
animation-name: example;
}

因为我要动画的文本框的高度是可变的。

按照您要求的方式设置动画没有问题:

@keyframes example {
0%   {height: 0px;}
100% {height: 100%;}
}
.container {
height: auto; 
animation: example 2s infinite;
background-color: lightgreen;
width: 100px;
}
html, body {
height: 100%;
}
<div class="container"></div>

我对你在问什么感到非常困惑,但这是我愚蠢的假设。 我假设你在问你是否可以在@keyframes中使用%单位.

是的。您可以在 CSS 关键帧中使用百分比。

最新更新