小编AzD*_*per的帖子

CSS 动画不起作用

我制作了 2 个动画,第一个可以正常工作,而第二个则不能。尽管两者几乎相同,但它不起作用。我将不胜感激任何帮助!

#menuAnim1 {
  height: 8px;
  background: black;
  position: relative;
  top: 50px;
  animation: widthStretch 4s ease-out;
  animation-fill-mode: forwards;
}

#menuAnim2 {
  width: 8px;
  background: black;
  position: relative;
  left: 50px;
  animation: heightStretch 4s ease-out;
  animation-fill-mode: forwards;
}

@keyframes widthStretch {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes heightStretch {
  from {
    height: 0;
  }
  to {
    height: 100%;
  }
}
Run Code Online (Sandbox Code Playgroud)
<div id='menuAnim1'></div>
<div id='menuAnim2'></div>
Run Code Online (Sandbox Code Playgroud)

你现在可以明白我的意思了。第二个应该增加它的高度,然后穿过第一个,但事实并非如此。

html css css-animations

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

css ×1

css-animations ×1

html ×1