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>
相关推荐
Vincent_czr13 小时前
iOS中常常遇到后端返回JSON出现null值问题
前端
问心无愧051313 小时前
ctf show web入门90
前端·笔记
yingyima13 小时前
午夜惊魂:用 Shell 脚本和 Hey Cron 解决服务器定时报警
前端
青山Coding13 小时前
Cesium应用(五):通视分析,解锁三维场景的”无遮挡“视野
前端·cesium
JavaAgent架构师14 小时前
前端AI工程化(三):异步编程与并发控制
前端·人工智能
独泪了无痕14 小时前
利用vue-pdf-embed实现PDF文件的预览
前端·vue.js
Exploring14 小时前
Hola 计算器 v1.0.1 发布:个税计算全面升级,劳务报酬也能算清楚了!
前端
Pan Zonghui14 小时前
个人开源技术博客前端
前端·开源
kyriewen14 小时前
我让AI替我写Git提交信息,老板以为我每天工作16小时
前端·javascript·git