无缝滚动 上下 /左右 方向滚动

上下 方向滚动

<template>
  <div class="scroll-wrap">

    <div class="scroll-content">
      <vue3-seamless-scroll class="scroll-list" :list="list" :hover="true" :step="0.4" :wheel="true" :isWatch="true">
        <ul class="scroll-ul" v-for="(item, index) in list" :key="index">
          <li class="scroll-li">
            <span style="min-width: 80px; width: calc(100% - 180px)">{{ item.title }}</span>
          </li>
        </ul>
      </vue3-seamless-scroll>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import { Vue3SeamlessScroll } from "vue3-seamless-scroll";

const list = ref([
  {
    title: "Vue3.0 无缝滚动组件展示数据第1条",
    date: Date.now(),
  },
  {
    title: "Vue3.0 无缝滚动组件展示数据第2条",
    date: Date.now(),
  },
  {
    title: "Vue3.0 无缝滚动组件展示数据第3条",
    date: Date.now(),
  },
  {
    title: "Vue3.0 无缝滚动组件展示数据第4条",
    date: Date.now(),
  },
  {
    title: "Vue3.0 无缝滚动组件展示数据第5条",
    date: Date.now(),
  },
  {
    title: "Vue3.0 无缝滚动组件展示数据第6条",
    date: Date.now(),
  },
  {
    title: "Vue3.0 无缝滚动组件展示数据第7条",
    date: Date.now(),
  },
  {
    title: "Vue3.0 无缝滚动组件展示数据第8条",
    date: Date.now(),
  },
  {
    title: "Vue3.0 无缝滚动组件展示数据第9条",
    date: Date.now(),
  },
]);   
</script>

<style scoped>
.scroll-wrap {
  width: 500px;
  height: 350px;
  overflow: hidden;
}

.scroll-header,
.scroll-content {
  width: 100%;
  display: flex;
}

.scroll-list {
  width: 100%;
  overflow: hidden;
}

.scroll-ul {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.scroll-li {
  width: 100%;
  display: flex;
  line-height: 35px;
}

.scroll-li>span {
  display: flex;
  height: 35px;
  line-height: 35px;
  border-top: 1px solid #dcdfe6;
  border-left: 1px solid #dcdfe6;
  padding-left: 5px;
  overflow: hidden;
}

.scroll-li>span:last-child {
  border-right: 1px solid #dcdfe6;
}

.scroll-header .scroll-li {
  background-color: #F8F9FF;
}

.scroll-header .scroll-li>span {
  font-weight: bold;
  border-top: none;
}

.scroll-content .scroll-ul:last-child .scroll-li {
  border-bottom: 1px solid #dcdfe6;
}
</style>

左右方向滚动

<template>
  <div class="scroll-wrap">
    <div class="scroll-content">
      <vue3-seamless-scroll class="scroll-list" :list="list" direction="left" :hover="true" :step="0.4" :wheel="true"
        :isWatch="true">
        <div class="scroll-container">
          <div class="scroll-item" v-for="(item, index) in list" :key="index">
            <span>{{ item.title }}</span>
          </div>
        </div>
      </vue3-seamless-scroll>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import { Vue3SeamlessScroll } from "vue3-seamless-scroll";

const list = ref([
  {
    title: "无缝滚动组件数据1",
    date: Date.now(),
  },
  {
    title: "无缝滚动组件数据2",
    date: Date.now(),
  },
  {
    title: "无缝滚动组件数据3",
    date: Date.now(),
  },
  {
    title: "无缝滚动组件数据4",
    date: Date.now(),
  },
  {
    title: "无缝滚动组件数据5",
    date: Date.now(),
  },
  {
    title: "无缝滚动组件数据6",
    date: Date.now(),
  },
  {
    title: "无缝滚动组件数据7",
    date: Date.now(),
  },
  {
    title: "无缝滚动组件数据8",
    date: Date.now(),
  },
]);   
</script>

<style scoped>
.scroll-wrap {
  width: 500px;
  height: 350px;
  overflow: hidden;
}

.scroll-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.scroll-list {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.scroll-container {
  display: flex;
  flex-direction: row;
  /* 确保子元素水平排列 */
  white-space: nowrap;
  /* 防止文本换行 */
}

.scroll-item {
  display: inline-block;
  /* 确保每个项目水平排列 */
  margin-right: 20px;
  /* 调整项目之间的间距 */
  line-height: 35px;
  white-space: nowrap;
}

.scroll-item span {
  display: inline-block;
  height: 35px;
  line-height: 35px;
  padding-left: 5px;
  overflow: hidden;
}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FFF_63456023

赠人玫瑰,手留余香 ~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值