js实现自定义滚动条的示例
(编辑:jimmy 日期: 2025/10/26 浏览:3 次 )
自定义滚动条
目录
- 代码实例
- 代码解析
- 下载源码链接
代码实例
* {
padding: 0;
margin: 0;
}
#box1 {
width: 500px;
height: 20px;
background: #999;
position: relative;
margin: 20px auto;
}
#box2 {
width: 20px;
height: 20px;
background: green;
position: absolute;
}
#box3 {
width: 0;
height: 0;
margin: 20px auto;
}
#box3 img {
width: 100%;
height: 100%;
}
<div id="box1">
<div id="box2"></div>
</div>
<div id="box3">
<img src="/UploadFiles/2021-04-02/1.jpg">
代码解析
elem.style.cssText是加在内嵌style中的
// oBox3.style.cssText是加在内嵌style中的
oBox3.style.cssText += 'width:' + w + 'px;height:' + h + 'px;
下载源码链接
星辉的Github
以上就是js实现自定义滚动条的示例的详细内容,更多关于js实现自定义滚动条的资料请关注其它相关文章!
下一篇:vue移动端下拉刷新和上滑加载