vue动态上下平缓轮播滚动

数据超过十条开始滚动

  <div class="left-block">
          <div class="list-block" :class="{ marquee: arr.length > 10 }">
            <div class="list" :style="`animation: row ${arr.length * 1}s linear infinite;`">
              <div v-for="(item, index) in arr" :key="index" class="dongtai">
                <p>{{ item.XXXX }}</p>
              </div>
            </div>
          </div>
        </div>
 data() {
    return {
      arr: []
    }
  },
  methods: {
    // 获取动态
    getJointSituationResults() {
      apiBase.xxxxx, res => { //接口
        this.srr = [ // 数据复制一下 让轮播滚动衔接更顺滑
          ...res.data.content,
          ...res.data.content
        ]
      })
    }
  },
.left-block {
        position: absolute;
        width: 95%;
        text-align: center;
        color: rgba(255, 255, 255, 0.8);
        height: 89%;
        .list-block {
          height: 100%;
          overflow: hidden;
          .list {
            height: 100%;
            overflow: auto;
            /*IE*/
            -ms-overflow-style: none;
            /*火狐*/
            overflow: -moz-scrollbars-none;
            /*谷歌*/
            &::-webkit-scrollbar { //隐藏滚动条
              display: none;
            }
            .dongtai {
              width: 100%;
              position: relative;
              text-align: left;
              line-height: 25px;
              font-size: 18px;
              margin: 10px;
              p {
                font-size: 18px;
                font-family: SourceHanSansCN;
                font-weight: 400;
                color: #ffffff;
                line-height: 20px;
              }
            }
          }
        }
        //动画 平缓上偏移50%
        @keyframes row {
          0% {
          }
          100% {
            transform: translateY(-50%);
          }
        }
        .marquee {
          position: relative;
          .list {
            /* 调用动画 */
            height: initial;
            overflow: initial;
            // animation: row 15s linear infinite;  // 原先是写死的速度,由于数据不固定在html写了
          }
          .list:hover { // 鼠标悬停停止滚动
            animation-play-state: paused !important;
          }
        }
      }
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以使用Vue.js和一些现成的JavaScript库来实现上下滚动轮播视频轮播放窗口。以下是一些可能有用的步骤: 1. 安装和导入Vue.js和相关的JavaScript库,例如swiper.js和video.js。 2. 在Vue组件中创建一个包含视频列表的容器,使用CSS将其设置为所需的大小和形状,并将其设置为可滚动的。例如: ```html <template> <div class="video-container"> <div class="video-list"> <div class="video-item" v-for="video in videos" :key="video.id"> <video :src="video.src" class="video-js" controls></video> </div> </div> </div> </template> <script> import Swiper from 'swiper'; import 'swiper/css/swiper.css'; import videojs from 'video.js'; import 'video.js/dist/video-js.css'; export default { data() { return { videos: [ { id: 1, src: 'path/to/video1.mp4' }, { id: 2, src: 'path/to/video2.mp4' }, { id: 3, src: 'path/to/video3.mp4' }, // ... ] } }, mounted() { // 初始化swiper轮播组件 new Swiper('.video-container', { direction: 'vertical', slidesPerView: 'auto', }); // 初始化video.js视频播放组件 videojs(document.querySelectorAll('.video-js')); } } </script> <style> .video-container { width: 100%; height: 400px; /* 设置容器高度 */ overflow: hidden; /* 设置容器可滚动 */ } .video-list { display: flex; flex-direction: column; height: 100%; /* 设置视频列表高度 */ } .video-item { flex: 1; display: flex; align-items: center; justify-content: center; background-color: #f5f5f5; } </style> ``` 3. 在mounted生命周期钩子中初始化swiper轮播组件和video.js视频播放组件。 4. 根据需要调整CSS样式以适应您的设计需求。 注意:此处只是一个简单的示例,您需要根据您的实际需求进行调整。同时,视频播放可能会涉及到一些版权问题,需要您自行处理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值