div实现隐藏滚动条拖动滚动效果
有时候我们不想显示滚动条,但是又可以通过鼠标或者触摸滚动内容,以下整理了2套方案,通过2个div图层实现效果
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>BFW NEW PAGE</title> <script id="bfwone" data="dep=jquery.17&err=0" type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/bfwone.js"></script> <script type="text/javascript"> bready(function() { use(["colpick", "colpick"], function() { $('#picker').colpick({ flat: true, layout: 'hex', submit: 0 }); }); }); </script> <style> #parent { width: 100%; height: 30px; overflow: hidden; white-space: nowrap; } #child { width: 100%; height: 50px; overflow-y: scroll; padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */ box-sizing: content-box; /* So the width will be 100% + 17px */ } #parent2 { width: 100%; height: 30px; overflow: hidden; position: relative; white-space: nowrap; } #child2 { height: 50px; position: absolute; top: 0; bottom: 0; left: 0; right: -17px; /* Increase/Decrease this value for cross-browser compatibility */ overflow-y: scroll; } </style> </head> <body> <h1>第一种方式</h1> <div id="parent"> <div id="child"> 内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容 </div> </div> <h1>第二种方式</h1> <div id="parent2"> <div id="child2"> 内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容 </div> </div> </body> </html>
网友评论0