猿问
回到首页
个人中心
反馈问题
注册登录
下载APP
首页
课程
实战
体系课
手记
专栏
慕课教程
如何隐藏掉手机端页面的滚动条
::-webkit-scrollbar在手机端不管用。有没有其他办法?手机端手机端!!!!
哔哔one
浏览 647
回答 1
1回答
万千封印
1.在需要滚动的层scrollbar外再加一个层hide-scrollbar。2.然后将这个层hide-scrollbar的overflow:hidden。3.将层scrollbar的position:absolute,并且把需要滚动的那一边的大小设置刚好滚动条的大小(用calc实现)。<!DOCTYPE html><html><head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"> <title>Document</title> <style> body { max-width: 325px; padding: 10px 30px; } .hide-scrollbar { position: relative; width: 100%; height: 100px; overflow: hidden; } .scrollbar { position: absolute; width: calc(100% + 18px); height: 100%; background-color: #ccc; overflow-y: auto; } .scrollbar ul { margin: 0; } .scrollbar.row { width: 100%; height: calc(100% + 18px); overflow-y: hidden; overflow-x: auto; } .scrollbar.row ul { white-space: nowrap; } .scrollbar.row ul li { display: inline-block; line-height: 100px; } </style></head><body> <h4>竖向</h4> <div class="hide-scrollbar"> <div class="scrollbar"> <ul> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> </ul> </div> </div> <h4>横向</h4> <div class="hide-scrollbar"> <div class="scrollbar row"> <ul> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> <li>demo-list</li> </ul> </div> </div></body></html>
0
0
0
打开App,查看更多内容
随时随地看视频
慕课网APP
相关分类
JavaScript
继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续