uniapp 自定义滚动条颜色,并且一直显示


页面单独定义

/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
/deep/::-webkit-scrollbar{
  width: 10px!important;
  height: 10px!important;
  background-color: rgba(0,0,0,0)!important;
}

/*定义滚动条轨道 内阴影+圆角*/
/deep/::-webkit-scrollbar-track{
  border-radius: 5px!important;
  background-color: rgba(0,0,0,0)!important;
}

/*定义滑块 内阴影+圆角*/
/deep/::-webkit-scrollbar-thumb{
  border-radius: 5px!important;
  background-color: #bbb!important;
}

 

全局定义

第一步:app.vue文件,增加以下内容

/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar{
  width: 5px!important;
  height: 5px!important;
  background-color: rgba(0,0,0,0)!important;
}

/*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track{
  border-radius: 5px!important;
  background-color: rgba(0,0,0,0)!important;
}

/*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb{
  border-radius: 5px!important;
  background-color: #999!important;
}

 

 

第二步:使用

<scroll-view style="height: 300rpx;background-color: yellow;"  :scroll-y="true">
  <view style="width: 100%;">
    <view class="item">1</view>
    <view class="item">2</view>
    <view class="item">3</view>
    <view class="item">4</view>
    <view class="item">5</view>
  </view>
</scroll-view>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM