html - 动画不工作。从左边移动 :0px to left :200px

标签 html css animation css-animations

我是 html5 和 css3 的新手,我只是在玩弄不同的 css3 动画功能。谁能指出下面代码中的错误?从左 0px 到左 200px 的移动不起作用。

<!doctype html>
<html>
    <head>
    <title>
        Experiment: animation with movements
    </title>

    <style>
        footer{
            width: 100px;
            height: 100px;
            background: red;
            animation: mymove 5s;
            animation-play-state: running;
        }

        @-moz-keyframes mymove {
            from {left:50px;}
            to {left:200px;}
        }
        @keyframes mymove {
            from {left:50px;}
            to {left:200px;}
        }
    </style>
</head>
<body>

<footer>
</footer>

</body>
</html>

最佳答案

position: relative; 添加到 footer CSS

footer {
  position: relative;
  width: 100px;
  height: 100px;
  background: red;
  animation: mymove 5s;
  animation-play-state: running;
}

@-moz-keyframes mymove {
  from {
    left: 50px;
  }
  to {
    left: 200px;
  }
}

@keyframes mymove {
  from {
    left: 50px;
  }
  to {
    left: 200px;
  }
}
<footer></footer>

关于html - 动画不工作。从左边移动 :0px to left :200px,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56295975/

相关文章:

java - 在游戏中使用图形的最佳方式

CSS/HTML : Designing with pixels for multi DPI devices? 保持相同尺寸?

html - 提交按钮无边框 - 高度/对齐问题

css - 内部分页符 : avoid - not working in Chrome

javascript - 单人纸牌游戏 - 将纸牌堆叠在一起

html - 引导表单按钮和订阅 float 问题

animation - 将动画 3D 模型转换为 Quake 2 的模型

animation - d3 js 退出动画无法正常工作

javascript - 如果我在表格外单击,如何隐藏菜单

jquery - 平稳地改变元素的位置