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>
相关推荐
默_笙11 小时前
💫 闭包是个背包:拆解小米前端面试题里的三道"闭包陷阱"
前端·javascript·面试
天若有情67311 小时前
粒子星空背景单页HTML模板|炫酷动态星空特效网页(纯前端)
前端·html·css动画·网页特效·粒子星空·静态网页模版
工业涂料百问11 小时前
【趋势前沿】系列(三)工业涂料国产替代的三个台阶:航空、海工、电子的突破路径与认证壁垒
前端
前端snow11 小时前
ai agent --- agentic RAG
前端
gyratesky11 小时前
记录一种很新的大屏开发方式
前端·数据可视化
xy345312 小时前
Axure 9.0 中继器核心结构
前端·ui·html·axure·原型·产品设计
老王以为13 小时前
走进 AI Agent 第四篇(上):知识获取管道——RAG 基础
前端·人工智能·全栈
夏天要喝冰可乐13 小时前
一处写作,多平台分发:我给掘金做了一款开源 Chrome 插件
前端·chrome·vibecoding
货拉拉技术13 小时前
货拉拉开源Hadice:安卓 & 鸿蒙桌面调试工具
前端