运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #scroller { width: 300px; height: 100px; overflow-y: scroll; } </style> </head> <body> <h1>Change scrollbar color with JavaScript</h1> <p><strong>Note:</strong> The scrollbar-color property only works in Firefox.</p> <div id="scroller"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur... </div> <p>Click the "Try it" button to change the color of the scrollbar</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("scroller").style.scrollbarColor = "red blue"; } </script> </body> </html>