【问题标题】:Can I specify percentages in keyframes?我可以在关键帧中指定百分比吗?
【发布时间】:2017-12-27 23:40:59
【问题描述】:

例如,我想指定 100%

@keyframes example {
    0%   {height: 0px;}
    100% {height: 100%;}
}

container {
    height: auto; //variable height
    animation-name: example;
}

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

【问题讨论】:

  • 请提供反对意见的解释。谢谢。

标签: css animation css-animations keyframe


【解决方案1】:

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

@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>

【讨论】:

    【解决方案2】:

    我很困惑你在问什么,但这是我的愚蠢假设。我假设您在问是否可以在 @keyframes 中使用 % 单位。

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

    【讨论】:

      猜你喜欢
      • 2016-11-23
      • 1970-01-01
      • 1970-01-01
      • 2016-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多