1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > jQuery自定义滚动条完整实例【jquery】

jQuery自定义滚动条完整实例【jquery】

时间:2023-03-23 15:00:24

相关推荐

jQuery自定义滚动条完整实例【jquery】

web前端|js教程

jQuery,自定义,滚动条,jQuery自定义滚动条

web前端-js教程

网页播放器源码带歌词,win识别不了ubuntu,tomcat下载哪一个版本,网络爬虫实战二,php在后台改动后前台不显示,宜昌seo顾问lzw

很多时候,由于美观上的考虑,往往需要自定义各种各样的滚动条,因此,本人做了一个demo

虚拟主机销售系统源码,ubuntu终端安装命令,tomcat自带线程池吗,动物昆虫爬虫,html变量传输到php,侦探seolzw

运行效果截图如下:

微信平台 会员系统源码,vscode php所有插件,ubuntu 8.1,tomcat的账号密码,sqlite3insert语句,宠物网页设计模板,php测试数据库链接,域名和服务器名称,bootstrap常用插件下载,web前端的三大框架,数据爬虫教程,php状态,seo代表,代替springboot,标签和标题哪个重要性,物流公司网站模板,asp网页美化,卖水果网站模板,菜谱网站后台代码,jsp新闻编辑页面,php mysql新闻管理系统,matlab完整程序lzw

以下是代码部分:

$(function(){//内容高度var content = $("#div2"); //框的高度var box = $("#div1");//自定义的滚动条var scrollbar = $("#div3");var scroll=function(content,box,scrollbar){ var bigHeight = content.height(); var smallHeight = box.height(); var rate = smallHeight/bigHeight; var h = Math.floor(rate*smallHeight); scrollbar.height(h); var offset = box.offset() var offsetT = offset.top+1; scrollbar.mousedown(function(e){var divOffsetT = scrollbar.offset().top;var tempT = e.pageY-divOffsetT;function move(e){ var newH = e.pageY-tempT-offsetT; if(newH(smallHeight-h)){ newH=smallHeight-h; } var rate2 = (newH+h)/smallHeight; var contentH = Math.floor(bigHeight*rate2-smallHeight); content.css("top",-contentH+"px"); scrollbar.css("top",newH+"px");}$("body").on("mousemove",move);$("body").mouseup(function(){ $("body").off("mousemove",move);}); });}scroll(content,box,scrollbar); }); *{ margin:0; padding: 0;}body{ font-size: 12px;}#div1{ width: 200px; height: 300px; margin: 50px auto; position: relative; _overflow: hidden; border: 1px solid #000;}#div2{ width: 180px; position: absolute; top: 0; left: 5px;}#div3{ width: 10px; position: absolute; top: 0; right:5px; background: #000;}

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。