爱易网
IT新闻
IT新闻
爱易资讯
网站搭建
云虚拟主机教程
云服务器教程
Apache教程
IIS教程
Nginx教程
网站策划
站长文章
推广教程
淘宝客教程
网页设计
HTML教程
XHTML教程
CSS教程
HTML5教程
CSS3教程
JavaSript基础
JQuery教程
Node.js教程
前端技术
Ajax教程
Js特效
Xml教程
平面设计
页面UI设计
photoshop教程
程序开发
AI人工智能
Asp教程
Php教程
Asp.Net教程
Net Core教程
C#教程
Java教程
Jsp教程
开发技术
微信小程序教程
Uniapp开发教程
微信公众号开发
Andriod教程
IOS教程
DOS教程
Python教程
Docker教程
Windows Container教程
数据库
MSSQL教程
MySQL教程
Redis教程
Access教程
Oracle教程
数据库教程
操作系统
Linux教程
Windows教程
MAC教程
Cisco教程
交换机教程
防火墙教程
搜索
爱易网页
JS特效
可选择左右滚动的菜单
可选择左右滚动的菜单
日期:2014-05-18 浏览次数:20237 次
可选择左右滚动的菜单,带缓动效果.
以下是HTML网页特效代码,点击运行按钮可查看效果:
以下是程序代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>爱易网js特效频道,js.aiyiweb.com</title> <style> ul{margin:0;padding:0;list-style:none;width:100000px} li{margin:0;padding:0;width:100px;height:100px;display:block;float:left;margin-right:5px;background:#009900} #img_bag{width:640px;height:100px;background:#FF9900;margin:0 auto;} #img_bag a{float:left;width:20px;display:block;height:20px;font-weight:bold;} #img_bag #img{width:600px;height:100px;background:#ccc;overflow:hidden;float:left} #scrollBar{width:600px;height:20px;background:#FF0000;margin:0 auto;position:relative} #scroll{width:30px;height:20px;background:#000;cursor:pointer;position:absolute;} </style> </head> <body> <div id="img_bag"> <a href="javascript:void(0)" onmousedown="moveLeft()"><<</a> <div id="img"> <ul> <li>爱易网</li> <li>特效频道</li> <li>js.aiyiweb.com</li> <li>欢迎访问</li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </div> <a href="javascript:void(0)" onmousedown="moveRight()">>></a> </div> <div style="clear:both;"></div> <div id="scrollBar"> <div id="scroll" style="left:0"></div> </div> <script> function $(obj){return document.getElementById(obj)} var maxWidth=$("img").getElementsByTagName("ul")[0].getElementsByTagName("li").length*105; var isScroll=false; var modiLeft; $("scroll").onmousedown=function(evt){ isScroll=true; evt=(evt)?evt:((window.event)?window.event:null); if(evt.offsetX){ modiLeft=parseInt(evt.offsetX) } else{modiLeft=parseInt(evt.layerX)} } document.onmouseup=function(){ isScroll=false; } document.onmousemove=function(evt){ evt=(evt)?evt:((window.event)?window.event:null); if(evt&&isScroll){ $("scroll").style.left=parseInt(evt.clientX)-parseInt($("scrollBar").offsetLeft)-modiLeft+"px"; if(parseInt($("scroll").style.left)<0){$("scroll").style.left=0+"px"} if(parseInt($("scroll").style.left)>570){$("scroll").style.left=570+"px"} $("img").scrollLeft=parseInt($("scroll").style.left)*((maxWidth-600)/570); } } var targetx = 200;//一次滚动距离 var dx; var a=null; function moveLeft(){ var le=parseInt($("img").scrollLeft); if(le>200){ targetx=parseInt($("img").scrollLeft)-200; } else{targetx=parseInt($("img").scrollLeft)-le-1} scLeft(); } function scLeft(){ dx=parseInt($("img").scrollLeft)-targetx; $("img").scrollLeft-=dx*.3; $("scroll").style.left=parseInt($("img").scrollLeft)*(570/(maxWidth-600))+"px"; if(parseInt($("scroll").style.left)<0){$("scroll").style.left=0+"px"} if(parseInt($("scroll").style.left)>570){$("scroll").style.left=570+"px"} clearScroll=setTimeout(scLeft,50); if(dx*.3<1){clearTimeout(clearScroll)} } function moveRight(){ var le=parseInt($("img").scrollLeft)+200; var maxL=maxWidth-600; if(le<maxL){ targetx=parseInt($("img").scrollLeft)+200; } else{targetx=maxL} scRight(); } function scRight(){ dx=targetx-parseInt($("img").scrollLeft); $("img").scrollLeft+=dx*.3; $("scroll").style.lef
上一篇:狡猾的按钮特效
下一篇:一款纯CSS打造的竖向导航菜单
免责声明:
本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
相关资料
更多>
诺基亚因充电器问题暂停销售Lumia 2520平板电脑
去看看外面的世界吧!别窝里斗了,中国在线旅游商们
工信部或本月17日向联通电信颁发FDD牌照
谷歌安卓全球副总裁为何跳槽中国企业小米?
阿里入股虎嗅:媒体的脊梁弯了?未必!
诺基亚称不会更名“微软移动” 5月还将发布新品
迅雷欲3300万美元收购金山快盘 预计9月完成
MIUI,有了它小米就无惧对手
苏宁易购成世界最慢电商 专家称其涉嫌违约
推荐阅读
更多>
华为变阵:任正非调整三大业务布局
OPPO Find7体验测 Find7综测
Google要求硬件厂商捆绑预装应用的协议曝光
解读苹果收购Beats背后动机:库克在想什么?
富士康欲用机器人产iPhone 6
八位知名设计师评iOS7:新鲜但复杂
摩托罗拉移动裁员关闭德州Moto X手机工厂
在线音乐出现“小米公司”不是没有可能
中兴引进黑莓三个核心团队
HTC与苹果三星距离扩展 C2B形式成新武器
2013年至今中国互联网行业十大并购案汇总
网友爆料称微软雇水军宣传主机Xbox One
AMD Q1净亏1.46亿美元 转战SOC拥抱ARM求变
三星起诉LG在冰箱广告中玷污其企业笼统
京东物流"最后一公里":颠覆阿里或者被阿里干掉
2018年阿里云双11活动如何参加?1折优惠大攻略
中移动推动感地带3G网聊卡 火拼微信沃卡
微信收费形式三选一 腾讯或变身运营商
微软最后的救命稻草Win 8份额继续上升
从旗下三大业务BG发展看华为的过去现在和未来