爱易网
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 浏览次数:20218 次
可选择左右滚动的菜单,带缓动效果.
以下是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打造的竖向导航菜单
免责声明:
本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
相关资料
更多>
OPPO创始人陈明永:我们是怎么做营销的
同为70前后人,马云为什么总是像外星人那么瘦
酷派首抓4G时机大丰收,未来份额必降无疑
携程艺龙联手死磕同程 价钱烽烟蔓延至机票
阿里马云:我觉得互联网还有十年可以做
分析称iPhone 6明年初发布 屏幕变为4.8吋
携程收买酷讯成定局:转型互联网+投资
机器人进一步取代人类:将进军白领任务
iPhone 6将于10月17日内地上市:售5288元起
推荐阅读
更多>
英特尔VS苹果:移动芯片大战
广东移动董事长徐龙受调查 圈内对其褒贬不一
凑足了升级ios8所需要的5.7G空间,没料到“苹果”却变成“板砖”,iOS8还能一起愉快玩耍吗?
华为坚持不上市究竟为何?不差钱也不想冒风险
黑莓高管:黑莓能作为家“小众公司”活下来
小米2S试水高端化 纯“性价比”玩法已成过去式
苹果iWatch或使用量产液态金属 将取代玻璃
永不磨灭的九大尖端编程语言
盛大游戏走向衰落的根源:免费游戏模式惹的祸
移动联通回应税率改革:短期内收入利润将大减
iSuppli:上网本将于2015年退出市场
阿里国际化再落子:2.49亿美元投资新加坡邮政
科技巨匠体验谷歌眼镜:戴上了就不想摘上去
迅雷再次在美提交IPO申请
携程收买酷讯成定局:转型互联网+投资
广东移动高层受调查 中移动或现更大反腐风暴
优酷土豆兼并一年:依然处于烧钱形状
论:三大运营商运用商店逆袭并非不能够
FB上广告费用昂贵而且效果不及Twitter
银联布局二维码支付,“擦边球”生态不能自救