自定义滚动条样式
来源:互联网 发布:淘宝多肉植物哪家好 编辑:程序博客网 时间:2024/05/01 05:57
<style type="text/css"> #wraper{position:relative;width:300px;height:200px;padding-bottom:10px;background-color:#F6F6F6;overflow:hidden;} #slider{position:absolute;width:600px;top:0;left:0;margin:0;line-height:1.5;font-size:12px;color:#333;} #pannel{position:absolute;right:0;bottom:0;width:12px;height:100%;background-color:#F1F1F1;} #drag{position:absolute;right:0;width:12px;height:80px;background-color:#BCBCBC;cursor:pointer;} </style> <div id="wraper"> <div id="slider"> <p>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦</p> <p>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦</p> <p>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦</p> </div> <div id="pannel"> <div id="drag"></div> </div> </div> <script type="text/javascript"> var o1 = document.getElementById('slider'), o2 = document.getElementById('pannel'), o3 = document.getElementById('drag'); function customBar(oSlider, oPanel, oTrigger){ this.parent = oSlider.parentNode; this.slider = oSlider; this.panel = oPanel; this.trigger = oTrigger; this.h1 = this.parent.clientHeight; this.h2 = this.slider.offsetHeight; this.h3 = this.panel.clientHeight; this.h4 = this.trigger.offsetHeight; this.k = (this.h2 - this.h1)/(this.h3 - this.h4); this.dis = 0; this.flag = false; this.init(); } customBar.prototype = { init: function(){ if(this.k <= 0){ this.panel.style.display = 'none'; return; } this.slider.style.top = '0px'; this.trigger.style.top = '0px'; this.bind(); }, bind: function(){ var that = this; this.trigger.onmousedown = function(e){ that.down.call(that, e); } this.trigger.onmousemove = document.onmousemove = function(e){ that.move.call(that, e); } this.trigger.onmouseup = document.onmouseup = function(e){ that.up.call(that, e); } }, down: function(e){ var e = window.event || e, y1 = e.y || e.pageY, y2 = parseInt(this.trigger.style.top); this.dis = (y1 - y2); this.flag = true; this.move(e); }, move: function(e){ if(!this.flag) return;window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty(); //防止拖拽时文本被选中 var e = window.event || e, y1 = e.y || e.pageY, dis; dis = Math.min(Math.max(y1 - this.dis, 0), (this.h3 - this.h4)); this.slider.style.top= -dis * this.k + 'px'; this.trigger.style.top = dis + 'px'; }, up: function(){ this.flag = false; }, wheel: function(){ } } var ss = new customBar(o1, o2, o3); </script>
0 0
- 自定义滚动条样式
- 自定义滚动条样式
- 自定义滚动条样式
- CSS自定义滚动条样式
- CSS自定义滚动条样式
- CSS自定义滚动条样式
- CSS自定义滚动条样式
- Qt 自定义 滚动条 样式
- Qt 自定义 滚动条 样式
- Qt 自定义 滚动条 样式
- Qt 自定义 滚动条 样式
- 自定义浏览器滚动条样式
- css自定义滚动条样式
- CSS3自定义滚动条样式
- Qt 自定义 滚动条 样式
- CSS3自定义滚动条样式
- CSS3自定义滚动条样式
- CSS3自定义滚动条样式
- 黑马程序员 JAVA jar包的创建和操作
- 建立git仓库及同步SDK
- js怎么样控制打开网页窗口的大小,HTML如何关闭窗口大全(经典+有用+常用)
- 传值
- 学习 GCC编译器使用1
- 自定义滚动条样式
- 通过SQL Server 2008 访问MySQL
- 8.1 使用行为集合
- p4 add 目录
- [Elasticsearch] 索引管理 (五) - 默认映射,重索引,索引别名
- Android学习笔记三:第一个应用程序的扩充
- CADisplayLink 及定时器的使用
- 盘点互联网巨头奉献的十大开源安全工具
- 学习 GCC编译器使用2