纯css实现文字走马灯

纯css实现文字走马灯

主要用到了css3中animation,效果和代码如下

在这里插入图片描述

<!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;
      -webkit-tap-highlight-color: transparent;
      -webkit-touch-callout: none;
      user-select: none;
      -webkit-user-select: none;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
    }

    body {
      width: 100vw;
      min-height: 100vh;
    }

    .wrap .info {
      height: 20px;
      margin: 10px;
      font-size: 14px;
      color: white;
      padding: 0 5px;
      background-color: black;
      display: flex;
      align-items: center;
      border-radius: 4px;
    }

    .wrap .info .words-inner {
      white-space: nowrap;
      overflow: hidden;
      margin: 0 0 0 5px;

    }

    .wrap .info .words-inner .words {

      position: relative;
      width: fit-content;
      animation: move 8s linear infinite;
    }

    .wrap .info .words-inner .words::after {
      position: absolute;
      right: -100%;
      content: attr(text);
    }

    @keyframes move {
      0% {
        transform: translateX(5%);
      }

      100% {
        transform: translateX(-100%);
      }
    }

    .wrap .info img {
      width: 10px;
      height: 10px;
      object-fit: cover;
    }
  </style>
</head>

<body>

  <div class="wrap">
    <div class="info">
      <!-- 图片可以自定义 -->
      <img src="./images/top-one.png" alt="">:
      <div class="words-inner">
        <p class="words">
          测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试结束
        </p>
      </div>
    </div>
  </div>
</body>

</html>```

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值