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>
相关推荐
phltxy1 小时前
Vue 核心特性实战指南:指令、样式绑定、计算属性与侦听器
前端·javascript·vue.js
Byron07072 小时前
Vue 中使用 Tiptap 富文本编辑器的完整指南
前端·javascript·vue.js
css趣多多2 小时前
地图快速上手
前端
zhengfei6112 小时前
面向攻击性安全专业人员的一体化浏览器扩展程序[特殊字符]
前端·chrome·safari
码丁_1173 小时前
为什么前端需要做优化?
前端
Mr Xu_3 小时前
告别硬编码:前端项目中配置驱动的实战优化指南
前端·javascript·数据结构
Byron07073 小时前
从 0 到 1 搭建 Vue 前端工程化体系:提效、提质、降本实战落地
前端·javascript·vue.js
哆啦code梦3 小时前
前端存储三剑客:localStorage、sessionStorage与Cookie解析
前端·前端存储
徐小夕@趣谈前端4 小时前
Web文档的“Office时刻“:jitword共建版2.0发布!让浏览器变成本地生产力
前端·数据结构·vue.js·算法·开源·编辑器·es6
Data_Journal4 小时前
如何使用 Python 解析 JSON 数据
大数据·开发语言·前端·数据库·人工智能·php