CSS实现无缝滚动

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      .box {
        width: 1000px;
        height: 200px;
        margin: 50px auto 0;
        border: 1px solid greenyellow;
        overflow: hidden;
        position: relative;
      }
      .inner {
        position: absolute;
        left: 0;
        top: 0;
        animation: move 25s linear infinite;
        display: flex;
        flex-wrap: nowrap;
      }
      img {
        width: 200px;
        height: 200px;
        flex-shrink: 0;
        object-fit: cover;
      }
      /* 鼠标移入暂停动画 */
      .inner:hover {
        animation-play-state: paused;
      }
      @keyframes move {
        100% {
          transform: translateX(-50%);
        }
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="inner">
        <img
          src="http://www.capablist.com/CellFilethumb/172297_1086579887.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172295_1086579873.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172296_1086579880.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172272_1086504795.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172271_1086504788.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172270_1086504779.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172147_1086419637.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172074_1086342425.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/148506_1085995866.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/148390_1085898777.png"
          alt=""
        />
        <!-- clone element -->
        <img
          src="http://www.capablist.com/CellFilethumb/172297_1086579887.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172295_1086579873.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172296_1086579880.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172272_1086504795.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172271_1086504788.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172270_1086504779.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172147_1086419637.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/172074_1086342425.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/148506_1085995866.png"
          alt=""
        />
        <img
          src="http://www.capablist.com/CellFilethumb/148390_1085898777.png"
          alt=""
        />
      </div>
    </div>
  </body>
</html>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值