此图片无缝隙滚动代码在IE8下使用兼容性较好,推荐phpcms v9首页模板中使用。效果如图:
首页模板代码:
- <P> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<A href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</A>">
- <html xmlns="<A href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</A>">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>滚动图片效果</title>
- <link href="style.css" rel="stylesheet" type="text/css" />
- <script type="text/javascript" src="sileder.js"></script>
- </head>
- <body>
- <div class="contant">
- <div class="ztbd">
- <div class="ztbd_t">
- <h2><a href="#">滚动图片效果</a></h2>
- <span class="span_more"><a href="#">more</a></span></div>
- <div class="blk_18"> <a onmouseup="ISL_StopUp_1()" class="LeftBotton" onmousedown="ISL_GoUp_1()" onmouseout="ISL_StopUp_1()" href="javascript:void(0);" target="_self"></a>
- <div class="pcont" id="ISL_Cont_1">
- <div class="ScrCont">
- <div id="List1_1">
- <ul>
- <li><a href="#" target="_blank"><img src="img/pic1.jpg" width="166px" height="108px"/></a></li>
- <li><a href="#" target="_blank"><img src="img/pic2.jpg" width="166px" height="108px"/></a></li>
- <li><a href="#" target="_blank"><img src="img/pic1.jpg" width="166px" height="108px"/></a></li>
- <li><a href="#" target="_blank"><img src="img/pic2.jpg" width="166px" height="108px"/></a></li>
- <li><a href="#" target="_blank"><img src="img/pic1.jpg" width="166px" height="108px"/></a></li>
- <li><a href="#" target="_blank"><img src="img/pic2.jpg" width="166px" height="108px"/></a></li>
- <li><a href="#" target="_blank"><img src="img/pic1.jpg" width="166px" height="108px"/></a></li>
- <li><a href="#" target="_blank"><img src="img/pic2.jpg" width="166px" height="108px"/></a></li>
- <li><a href="#" target="_blank"><img src="img/pic1.jpg" width="166px" height="108px"/></a></li>
- <li><a href="#" target="_blank"><img src="img/pic2.jpg" width="166px" height="108px"/></a></li>
- </ul>
- </div>
- <div id="List2_1"></div>
- </div>
- </div>
- <a onmouseup="ISL_StopDown_1()" class="RightBotton" onmousedown="ISL_GoDown_1()" onmouseout="ISL_StopDown_1()" href="javascript:void(0);" target="_self"></a> </div>
- <script type="text/javascript">
- picrun_ini()
- </script>
- </div>
- </div>
- </body>
- </html></P>
复制代码 css代码:
- .contant {
- MARGIN-TOP: 5px; WIDTH: 960px; position:relative
- }
- .ztbd {
- BORDER-BOTTOM: #e1e4e6 1px solid; BORDER-LEFT: #e1e4e6 1px solid; MARGIN-TOP: 10px; HEIGHT: 203px; BORDER-TOP: #779ab1 3px solid; BORDER-RIGHT: #e1e4e6 1px solid
- }
- .ztbd_t {
- BACKGROUND: url(img/ui.gif) 0px -89px; HEIGHT: 34px
- }
- .ztbd_t H2 {
- LINE-HEIGHT: 35px; PADDING-LEFT: 26px; FONT-FAMILY: "Microsoft Yahei", "微软雅黑", Tahoma, Arial, Helvetica, STHeiti; FLOAT: left; COLOR: #fff; FONT-SIZE: 15px
- }
- .ztbd_t H2 A {
- COLOR: #056f8a; TEXT-DECORATION: none
- }
- .span_more {
- TEXT-INDENT: -9999px; MARGIN: 12px 10px 0px 0px; FLOAT: right; OVERFLOW: hidden
- }
- .span_more A {
- WIDTH: 31px; DISPLAY: block; BACKGROUND: url(img/ui.gif) 31px 45px; HEIGHT: 9px
- }
- .span_more A:hover {
- WIDTH: 31px; DISPLAY: block; BACKGROUND: url(img/ui.gif) 67px 45px; HEIGHT: 9px
- }
- .blk_18 {
- MARGIN-TOP: 8px; WIDTH: 960px; ZOOM: 1; FONT-SIZE: 12px; OVERFLOW: hidden
- }
- .blk_18 .pcont {
- WIDTH: 920px; FLOAT: left; MARGIN-LEFT: 2px; OVERFLOW: hidden
- }
- .blk_18 .ScrCont {
- WIDTH: 32766px; ZOOM: 1
- }
- .blk_18 .ScrCont LI {
- WIDTH: 174px; FLOAT: left; HEIGHT: 140px; MARGIN-LEFT: 10px
- }
- .blk_18 .ScrCont LI IMG {
- BORDER-BOTTOM: #b7c6d1 1px solid; BORDER-LEFT: #b7c6d1 1px solid; PADDING-BOTTOM: 3px; PADDING-LEFT: 3px; WIDTH: 166px; PADDING-RIGHT: 3px; DISPLAY: block; BACKGROUND: #fff; HEIGHT: 108px; BORDER-TOP: #b7c6d1 1px solid; BORDER-RIGHT: #b7c6d1 1px solid; PADDING-TOP: 3px
- }
- .blk_18 .ScrCont LI A:hover IMG {
- BORDER-BOTTOM-COLOR: #6c7f90; BORDER-TOP-COLOR: #6c7f90; BORDER-RIGHT-COLOR: #6c7f90; BORDER-LEFT-COLOR: #6c7f90
- }
- .blk_18 .ScrCont LI SPAN {
- TEXT-ALIGN: center; LINE-HEIGHT: 32px; DISPLAY: block; HEIGHT: 32px
- }
- .blk_18 .ScrCont LI A SPAN {
- COLOR: #333333; TEXT-DECORATION: none
- }
- .blk_18 .ScrCont LI A:hover SPAN {
- TEXT-DECORATION: underline
- }
- .blk_18 #List1_1 {
- FLOAT: left
- }
- .blk_18 #List2_1 {
- FLOAT: left
- }
- .blk_18 .LeftBotton {
- MARGIN-TOP: 25px; WIDTH: 12px; BACKGROUND: url(img/ui.gif) 30px -406px; FLOAT: left; HEIGHT: 70px
- }
- .blk_18 .RightBotton {
- MARGIN-TOP: 30px; WIDTH: 12px; BACKGROUND: url(img/ui.gif) 13px -406px; FLOAT: right; HEIGHT: 70px
- }
- .blk_18 .LeftBotton:hover {
- BACKGROUND: url(img/ui.gif) 64px -406px
- }
- .blk_18 .RightBotton:hover {
- BACKGROUND: url(img/ui.gif) 47px -406px
- }
- H2 {
- BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; BORDER-RIGHT: 0px; PADDING-TOP: 0px
- }
- UL {
- BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; BORDER-RIGHT: 0px; PADDING-TOP: 0px
- }
- LI {
- LIST-STYLE-TYPE: none; LIST-STYLE-IMAGE: none
- }
复制代码
js代码:
- // JavaScript Document
- //图片滚动列表 mengjia 070927
- var Speed_1 = 10; //速度(毫秒)
- var Space_1 = 20; //每次移动(px)
- var PageWidth_1 = 184 * 5; //翻页宽度
- var interval_1 = 7000; //翻页间隔
- var fill_1 = 0; //整体移位
- var MoveLock_1 = false;
- var MoveTimeObj_1;
- var MoveWay_1="right";
- var Comp_1 = 0;
- var AutoPlayObj_1=null;
- function GetObj(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}}
- function AutoPlay_1(){clearInterval(AutoPlayObj_1);AutoPlayObj_1=setInterval('ISL_GoDown_1();ISL_StopDown_1();',interval_1)}
- function ISL_GoUp_1(){if(MoveLock_1)return;clearInterval(AutoPlayObj_1);MoveLock_1=true;MoveWay_1="left";MoveTimeObj_1=setInterval('ISL_ScrUp_1();',Speed_1);}
- function ISL_StopUp_1(){if(MoveWay_1 == "right"){return};clearInterval(MoveTimeObj_1);if((GetObj('ISL_Cont_1').scrollLeft-fill_1)%PageWidth_1!=0){Comp_1=fill_1-(GetObj('ISL_Cont_1').scrollLeft%PageWidth_1);CompScr_1()}else{MoveLock_1=false}
- AutoPlay_1()}
- function ISL_ScrUp_1(){if(GetObj('ISL_Cont_1').scrollLeft<=0){GetObj('ISL_Cont_1').scrollLeft=GetObj('ISL_Cont_1').scrollLeft+GetObj('List1_1').offsetWidth}
- GetObj('ISL_Cont_1').scrollLeft-=Space_1}
- function ISL_GoDown_1(){clearInterval(MoveTimeObj_1);if(MoveLock_1)return;clearInterval(AutoPlayObj_1);MoveLock_1=true;MoveWay_1="right";ISL_ScrDown_1();MoveTimeObj_1=setInterval('ISL_ScrDown_1()',Speed_1)}
- function ISL_StopDown_1(){if(MoveWay_1 == "left"){return};clearInterval(MoveTimeObj_1);if(GetObj('ISL_Cont_1').scrollLeft%PageWidth_1-(fill_1>=0?fill_1:fill_1+1)!=0){Comp_1=PageWidth_1-GetObj('ISL_Cont_1').scrollLeft%PageWidth_1+fill_1;CompScr_1()}else{MoveLock_1=false}
- AutoPlay_1()}
- function ISL_ScrDown_1(){if(GetObj('ISL_Cont_1').scrollLeft>=GetObj('List1_1').scrollWidth){GetObj('ISL_Cont_1').scrollLeft=GetObj('ISL_Cont_1').scrollLeft-GetObj('List1_1').scrollWidth}
- GetObj('ISL_Cont_1').scrollLeft+=Space_1}
- function CompScr_1(){if(Comp_1==0){MoveLock_1=false;return}
- var num,TempSpeed=Speed_1,TempSpace=Space_1;if(Math.abs(Comp_1)<PageWidth_1/2){TempSpace=Math.round(Math.abs(Comp_1/Space_1));if(TempSpace<1){TempSpace=1}}
- if(Comp_1<0){if(Comp_1<-TempSpace){Comp_1+=TempSpace;num=TempSpace}else{num=-Comp_1;Comp_1=0}
- GetObj('ISL_Cont_1').scrollLeft-=num;setTimeout('CompScr_1()',TempSpeed)}else{if(Comp_1>TempSpace){Comp_1-=TempSpace;num=TempSpace}else{num=Comp_1;Comp_1=0}
- GetObj('ISL_Cont_1').scrollLeft+=num;setTimeout('CompScr_1()',TempSpeed)}}
- function picrun_ini(){
- GetObj("List2_1").innerHTML=GetObj("List1_1").innerHTML;
- GetObj('ISL_Cont_1').scrollLeft=fill_1>=0?fill_1:GetObj('List1_1').scrollWidth-Math.abs(fill_1);
- GetObj("ISL_Cont_1").onmouseover=function(){clearInterval(AutoPlayObj_1)}
- GetObj("ISL_Cont_1").onmouseout=function(){AutoPlay_1()}
- AutoPlay_1();
- }
- function startmarquee(elementID,h,n,speed,delay){
- var t = null;
- var box = '#' + elementID;
- $(box).hover(function(){
- clearInterval(t);
- }, function(){
- t = setInterval(start,delay);
- }).trigger('mouseout');
- function start(){
- $(box).children('ul:first').animate({marginTop: '-='+h},speed,function(){
- $(this).css({marginTop:'0'}).find('li').slice(0,n).appendTo(this);
- })
- }
- }
- //产品展示滚动图片结束
- //-->
复制代码
打包下载:
phpcms首页滚动图片代码.rar
(220.69 KB, 下载次数: 453)
|