<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script> // 计算浏览器滚动条在各浏览器的宽度 const scrollContainer = document.createElement('div'); const scrollContent = document.createElement('div'); scrollContainer.style = 'position:fixed;z-index:-1;width:50px;height:50px;overflow:scroll;'; scrollContent.style = 'height:100px;'; scrollContainer.append(scrollContent); document.body.append(scrollContainer); const scrollBarWidth = scrollContainer.offsetWidth - scrollContent.offsetWidth; console.log(scrollBarWidth) </script> </body> </html>
最近看到--计算浏览器滚动条在各浏览器的宽度
猜你喜欢
转载自blog.csdn.net/weixin_41869039/article/details/88862504
今日推荐
周排行