欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 前端技术 > vue >内容正文

vue

使用vue-happy-scroll 自定义滚动条

发布时间:2023/12/31 vue 51 豆豆
生活随笔 收集整理的这篇文章主要介绍了 使用vue-happy-scroll 自定义滚动条 小编觉得挺不错的,现在分享给大家,帮大家做个参考.


这里演示一下使用vue-happy-scroll 自定义滚动条的方式;

官方地址:https://github.com/tangdaohai/vue-happy-scroll


兼容性:


支持特性:


安装

npm i -D vue-happy-scroll

使用

引入

import { HappyScroll } from 'vue-happy-scroll' // 引入css,推荐将css放入main入口中引入一次即可。 import 'vue-happy-scroll/docs/happy-scroll.css'

组件

<template><div class="page8-content"><div class="lrc-box"><imgsrc="xxxxx.png"altclass="title"/><div style="height:401px;"><happy-scrollcolor="#740411"hide-horizontalsize="6":min-length-v="3"resizerightclass="happy-slow"><div class="content"><p class="red info">演唱:xxx</p><p class="red info">词:xxx</p><p class="red info">曲:xxx</p><p class="red info">版权:xxx</p><p style="margin-top:12px">人事纷纷</p><p>你总太天真</p><p>往后的余生</p><p>我只要你</p><p>往后余生</p><p>风雪是你</p><p>平淡是你</p><p>清贫也是你</p><p>四季冷暖是你</p><p>目光所至</p><p>也是你</p><p>往后余生</p><p>风雪是你</p><p>平淡是你</p><p>清贫也是你</p><p>荣华是你</p><p>心底温柔是你</p><p>目光所至</p><p>也是你</p><p>目光所至</p><p>也是你</p></div></happy-scroll></div></div><div class="last-p" @click="showTip"></div></div> </template><script> import { HappyScroll } from 'vue-happy-scroll' // 引入css,推荐将css放入main入口中引入一次即可。 import 'vue-happy-scroll/docs/happy-scroll.css' export default {name: 'Eight',components: {HappyScroll},mounted() {//this.setVoice()},methods: {setVoice() {let video = document.getElementById('video')video.volume = 0.2},showTip() {this.$layer.toast({icon: 'icon-check',content: '这是最后一页啦,可以往前翻看哦~',time: 2000,})},}, } </script> <style lang="scss"> .happy-scroll-container .happy-scroll-content {display: inline-block;width: 100%; } .happy-scroll-content :nth-of-type(1) {margin-left: -4%; }.happy-scroll-container {overflow-x: hidden; } </style><style lang="scss" scoped> .happy-slow {-webkit-overflow-scrolling: touch; } .page8 {background: url(xxxxx.jpg)no-repeat;background-size: cover;margin-top: -1px; }.video-box {background: url(xxxxx.jpg);width: 647px;height: 363px;margin: 50px auto 0;padding: 7px;box-sizing: border-box;video {display: block;width: 100%;height: 100%;} } .lrc-box {text-align: center;font-size: 22px;color: #fff;line-height: 38px;padding-top: 95px;margin-right: 44px;position: relative;z-index: 1;&:after {content: '';position: absolute;right: 4px;top: 92px;bottom: 0;width: 2px;background: #681416;z-index: -1;}.title {position: absolute;left: 50%;top: 32px;transform: translateX(-50%);}p {margin: 0;line-height: 48px;height: 48px;}strong {font-size: 30px;}.red {color: #ad2116;}.info {line-height: 34px;height: 34px;}.dot-btn {width: 10px;height: 10px;border-radius: 50%;background-color: #ad2116;position: absolute;top: 0;right: -6px;} } .last-p {background: transparent;width: 41px;height: 961px;float: left;position: absolute;top: 0;right: 0px; } </style>

总结

以上是生活随笔为你收集整理的使用vue-happy-scroll 自定义滚动条的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。