css3 实现文字横幅无缝滚动

css3 实现文字横幅无缝滚动

使用 css3 关键帧 @keyframesanimation 属性实现文字横幅无缝滚动。

html 复制代码
<template>
  <div class="skiHallBanner">
    <div class="skiHallBanner-text">
      <span>{{ text }}</span>
    </div>
  </div>
</template>

<script>
import '@/utils/rem/skiHallBanner'

export default {
  name: 'SkiHallBanner',
  data() {
    return {
      text: 'xxx公告xxx公告xxx公告xxx公告xxx公告'.repeat(2),
    }
  },
}
</script>

<style lang="scss" scoped>
.skiHallBanner {
  width: 2300px;
  height: 230px;
  background: url('../../assets/images/skiHall/banner.png') no-repeat 100%/100%
    100%;

  &-text {
    position: relative;
    width: 2160px;
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
    white-space: nowrap;

    span {
      position: absolute;
      top: 0;
      font-size: 49px;
      font-family: Adobe Heiti Std;
      font-weight: normal;
      font-style: italic;
      color: #e4f2ff;
      text-align: left;
      line-height: 4.6;
      text-shadow: 5px 7px 0px rgba(0, 66, 255, 0.2),
        16px 23px 16px rgba(14, 19, 48, 0.52);

      animation: 26s scroll linear infinite normal;

      &::before {
        content: '';
        display: inline-block;
        width: 2180px;
        height: 100%;
      }
    }
  }
}

@keyframes scroll {
  from {
    transform: translate(0%, 0);
  }
  to {
    transform: translate(-100%, 0);
  }
}
</style>
相关推荐
Roc.Chang9 分钟前
Vite 启动报错:listen EACCES: permission denied 0.0.0.0:80 解决方案
linux·前端·vue·vite
Desirediscipline21 分钟前
cerr << 是C++中用于输出错误信息的标准用法
java·前端·c++·算法
sunny_21 分钟前
前端构建产物里的 __esModule 是什么?一次讲清楚它的原理和作用
前端·架构·前端工程化
Soulkey2 小时前
复刻小红书Web端打开详情过渡动画
前端
yuki_uix2 小时前
你点了「保存」之后,数据都经历了什么?
前端
猪头男2 小时前
【从零开始学习Vue|第六篇】生命周期
前端
zheshiyangyang4 小时前
前端面试基础知识整理【Day-7】
前端·面试·职场和发展
猫头虎4 小时前
web开发常见问题解决方案大全:502/503 Bad Gateway/Connection reset/504 timed out/400 Bad Request/401 Unauthorized
运维·前端·nginx·http·https·gateway·openresty
qq_24218863324 小时前
3389端口内网转发概述
前端·经验分享·html
伊泽瑞尔4 小时前
2025年终总结
前端·程序员·ai编程