html - 如何使用 CSS 动画从左到右移动元素?

标签 html css

我想从左侧到右侧为图像设置动画。

#pot{

position:absolute;
-webkit-animation:linear infinite;
-webkit-animation-name: run;
-webkit-animation-duration: 5s;
}     
@-webkit-keyframes run {
    0% { left:  0%;}
    100%{ left : 100%;}
}
<div id = "pot">
<img src = "/image/qgNyF.png?s=328&g=1"width = "100px" height ="100px">
</div>

如何从左侧重新输入图像?

最佳答案

试试这个方法。

#pot {
  position: relative;
  overflow: hidden;
}

.images {
  animation: run 5s linear infinite;
}

.images img:nth-child(2) {
  position: absolute;
  left: -100%;
}

@keyframes run {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(100%);
  }
}
<div id="pot">
  <div class="images">
    <img src="/image/qgNyF.png?s=328&g=1" width="100px" height="100px">
    <img src="/image/qgNyF.png?s=328&g=1" width="100px" height="100px">
  </div>
</div>

关于html - 如何使用 CSS 动画从左到右移动元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65549238/

相关文章:

javascript - 我应该采取什么方法来连续跳到有条件且无循环的函数?

javascript - 如何在 google maps JavaScript API v3 上隐藏或禁用 google Logo 、页脚、版权?

html - 如何设置内联 SVG 背景?

css - 带有 id 和 css 的标签

html - 在选择器无法垂直对齐之前?

javascript - 使用javascript和正则表达式在html中查找div

javascript - jQuery 可变高度

css - 我需要将条形排列在底部,而不是顶部

javascript - 如何使图像不可见,但在按下指定图像的按钮时显示?

html - 什么是完成我的 "cross?"的简单 CSS 方法