今天记录一个很小的问题,在工作之中会经常遇到的,当页面元素溢出的时候会产生滚动条,这个时候需要页面样式优化:CSS实现隐藏滚动条但是可以滚动。
body::-webkit-scrollbar { display: none; }
示例代码
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> .cont { width: 200px; height: 200px; border: 1px solid #000000; overflow-x: hidden; } .cont::-webkit-scrollbar { display: none; } </style> </head> <body> <div class="cont"> <p>王小婷</p> <p>王小婷</p> <p>王小婷</p> <p>王小婷</p> <p>王小婷</p> <p>王小婷</p> </div> </body> </html>