本文实例讲述了javascript实现列表滚动的方法。分享给大家供大家参考。具体如下:
index.html如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <link rel="stylesheet" type="text/css" href="css/global.css" /> <script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.7.min.js">scroll_img.js如下:
function scroll_img(target,distance,show_width,li_width,mr){ this.distance=distance; //每次移动距离 this.target=$("#"+target); this.show_width=show_width; //显示区域宽度 this.li_width=li_width; //items宽度 this.mr=mr; //items间距 this.scrollbar=$("#"+target).find('ul'); this.position=0; this.direction=1; } scroll_img.prototype={ version:1.00, author:"yangfeifei", date:2011-11-21, initialize:function(){ var t=this; t.scrollbar.css('position','relative'); //初始动作 t.autoplay(); t.scrollbar.mouseover(function(){t.stop();}); //鼠标移到图片上停止自动播放 t.scrollbar.mouseout(function(){t.autoplay();}); //鼠标移出图片开始自动播放 }, right:function(){ var t=this; (-t.position)<t.total_length()"htmlcode">/*CSS reset*/ body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;font-family:arial,"宋体";} table{border-collapse:collapse;border-spacing:0;} fieldset,img{border:0;} address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:bold;} ol,ul{list-style-type:none;} caption,th{text-align:left;} h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}/*font-size:100%;的作用主要是改变它默认的大小,继承父体的字体大小*/ q:before,q:after{content:' ';} abbr,acronym{border:0;} .cb{clear:both;} .cl{clear:left;} .cr{clear:right;} .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;} .clearfix{display:inline-block;} * html .clearfix{height:1%;} .clearfix{display:block;} /*主体css*/ .scroll_img_wrap{width:612px;margin: 10px auto;} #scroll_img{width:590px;overflow:hidden;float:left;*position:relative;border: 1px #ccc solid;}/*可视区域宽度*/ .scroll_img_list{width:9999px;} .scroll_img_list li{float:left;width:140px;margin-right:10px;}/*items*/ .scroll_img_list li p{text-align:center;} .scroll_img_list li p a{text-decoration:none;color:#666;} .left_btn,.right_btn{float:left;}希望本文所述对大家的javascript程序设计有所帮助。
标签:
javascript,列表滚动
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“javascript实现列表滚动的方法”评论...