美文网首页
无缝切换跑马灯

无缝切换跑马灯

作者: 一个健康马 | 来源:发表于2024-02-20 09:38 被阅读0次

@keyframes move {
0% {
transform: translateX(0);
}
100% {
transform: translateX(‘这里是跑马灯所有子元素+第一个子元素的宽度总和’);
}
}

例子:

<template>
    <!-- 跑马灯 -->
  <div class="data-count-box-animation">
    <div class="animation-box">
      <span
        class="data-count-text-animation"
        >
        <slot></slot>
        <slot></slot>
        </span
      >
    </div>
  </div>
</template>
<script lang="ts"> 
</script>
<style lang="scss" scoped>
.data-count-box-animation {
  font-size: 0;
  background: #025eff1a;
  width:100%;
  box-sizing: border-box;
  padding: 0 4px;
  gap: 0px;
  height: 22px;
  border-radius: 2px;
  border: 0.5px solid #025eff;
  margin-top: 12px;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.animation-box {
  width: max-content;
  left: 0;
  position: absolute;
  white-space: nowrap;
  display: inline-flex;
  height: 22px;
  justify-content: space-between;
  animation: marquee 18s linear infinite;
}
.data-count-text {
  font-family: PingFang SC;
  font-size: 10px;
  font-weight: 400;
  height: 22px !important;
  line-height: 22px;
  margin: 0;
  color: #000000cc;
}
.data-count-text-animation {
  display: inline-block;
  font-family: PingFang SC;
  font-size: 10px;
  font-weight: 400;
  line-height: 22px;
  margin-right: 20px;
  color: #000000cc;
}
// @keyframes marquee {
//   0% {
//     transform: translateX(0%); /* 从右侧进入 */
//   }
//   100% {
//     transform: translateX(-100%); /* 向左移动到完全离开 */
//   }
// }
@keyframes marquee {
  0% {
    transform: translateX(0%); /* 从右侧进入 */
  }
  100% {
    transform: translateX(-50%); /* 向左移动到完全离开 */
  }
}
</style>

相关文章

  • 无缝切换~

    今天度过了愉快而充实的一天,具体的行程是这样的: 睡到自然醒,大概快十点了吧,然后喝酸奶,吃全麦面包垫垫肚子,做个...

  • 无缝切换

    我来到机场,这里虽不是人声鼎沸,却也是各色人等形色匆匆,背包的,推车的,客服优雅的声音,标准的手势,招牌式微笑,让...

  • 无缝切换

    大家好,今天想跟大家分享一个特别有意思的现象,就是如标题所说,一个人的思维方式居然可以做到无缝切换。 具体是怎样一...

  • (IM,直播,跑马灯,瀑布流,手势解锁...)开发中实用的组件(

    1.跑马灯 一个跑马灯的效果,同时可以支持两个方向的滚动;实现无缝衔接;https://github.com/On...

  • vue 跑马灯无-缝连接循环滚动

    跑马灯-无缝连接循环滚动 1、效果: 2、组件地址:vue-seamless-scroll[https://che...

  • 无缝轮播

    无缝细解过程 html css js 无缝轮播js切换动画 css代码 JS代码 循环无缝轮播 CSS js1.首...

  • jQuery实现轮播图无缝(无回滚)滚动切换效果

    HTML 无缝切换轮播图