热搜词
发表于 2014-3-7 14:46:01 | 显示全部楼层 |阅读模式
此图片无缝隙滚动代码在IE8下使用兼容性较好,推荐phpcms v9首页模板中使用。效果如图:

01.jpg

首页模板代码:



  1. <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>">
  2. <html xmlns="<A href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</A>">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <title>滚动图片效果</title>
  6. <link href="style.css" rel="stylesheet" type="text/css" />
  7. <script type="text/javascript" src="sileder.js"></script>
  8. </head>
  9. <body>
  10. <div class="contant">
  11.   <div class="ztbd">
  12.     <div class="ztbd_t">
  13.       <h2><a href="#">滚动图片效果</a></h2>
  14.       <span class="span_more"><a href="#">more</a></span></div>
  15.     <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>
  16.       <div class="pcont" id="ISL_Cont_1">
  17.         <div class="ScrCont">
  18.           <div id="List1_1">
  19.             <ul>
  20.               <li><a href="#" target="_blank"><img src="img/pic1.jpg" width="166px" height="108px"/></a></li>
  21.               <li><a href="#" target="_blank"><img src="img/pic2.jpg" width="166px" height="108px"/></a></li>
  22.               <li><a href="#" target="_blank"><img src="img/pic1.jpg" width="166px" height="108px"/></a></li>
  23.               <li><a href="#" target="_blank"><img src="img/pic2.jpg" width="166px" height="108px"/></a></li>
  24.                <li><a href="#" target="_blank"><img src="img/pic1.jpg" width="166px" height="108px"/></a></li>
  25.               <li><a href="#" target="_blank"><img src="img/pic2.jpg" width="166px" height="108px"/></a></li>
  26.               <li><a href="#" target="_blank"><img src="img/pic1.jpg" width="166px" height="108px"/></a></li>
  27.               <li><a href="#" target="_blank"><img src="img/pic2.jpg" width="166px" height="108px"/></a></li>
  28.                            <li><a href="#" target="_blank"><img src="img/pic1.jpg" width="166px" height="108px"/></a></li>
  29.               <li><a href="#" target="_blank"><img src="img/pic2.jpg" width="166px" height="108px"/></a></li>
  30.             </ul>
  31.           </div>
  32.           <div id="List2_1"></div>
  33.         </div>
  34.       </div>
  35.       <a onmouseup="ISL_StopDown_1()" class="RightBotton" onmousedown="ISL_GoDown_1()" onmouseout="ISL_StopDown_1()" href="javascript:void(0);" target="_self"></a> </div>
  36.     <script type="text/javascript">
  37.    picrun_ini()
  38. </script>
  39.   </div>
  40. </div>
  41. </body>
  42. </html></P>
复制代码
css代码:
  1. .contant {
  2. MARGIN-TOP: 5px; WIDTH: 960px; position:relative
  3. }
  4. .ztbd {
  5. 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
  6. }
  7. .ztbd_t {
  8. BACKGROUND: url(img/ui.gif) 0px -89px; HEIGHT: 34px
  9. }
  10. .ztbd_t H2 {
  11. LINE-HEIGHT: 35px; PADDING-LEFT: 26px; FONT-FAMILY: "Microsoft Yahei", "微软雅黑", Tahoma, Arial, Helvetica, STHeiti; FLOAT: left; COLOR: #fff; FONT-SIZE: 15px
  12. }
  13. .ztbd_t H2 A {
  14. COLOR: #056f8a; TEXT-DECORATION: none
  15. }
  16. .span_more {
  17. TEXT-INDENT: -9999px; MARGIN: 12px 10px 0px 0px; FLOAT: right; OVERFLOW: hidden
  18. }
  19. .span_more A {
  20. WIDTH: 31px; DISPLAY: block; BACKGROUND: url(img/ui.gif) 31px 45px; HEIGHT: 9px
  21. }
  22. .span_more A:hover {
  23. WIDTH: 31px; DISPLAY: block; BACKGROUND: url(img/ui.gif) 67px 45px; HEIGHT: 9px
  24. }

  25. .blk_18 {
  26. MARGIN-TOP: 8px; WIDTH: 960px; ZOOM: 1; FONT-SIZE: 12px; OVERFLOW: hidden
  27. }
  28. .blk_18 .pcont {
  29. WIDTH: 920px; FLOAT: left; MARGIN-LEFT: 2px; OVERFLOW: hidden
  30. }
  31. .blk_18 .ScrCont {
  32. WIDTH: 32766px; ZOOM: 1
  33. }
  34. .blk_18 .ScrCont LI {
  35. WIDTH: 174px; FLOAT: left; HEIGHT: 140px; MARGIN-LEFT: 10px
  36. }
  37. .blk_18 .ScrCont LI IMG {
  38. 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
  39. }
  40. .blk_18 .ScrCont LI A:hover IMG {
  41. BORDER-BOTTOM-COLOR: #6c7f90; BORDER-TOP-COLOR: #6c7f90; BORDER-RIGHT-COLOR: #6c7f90; BORDER-LEFT-COLOR: #6c7f90
  42. }
  43. .blk_18 .ScrCont LI SPAN {
  44. TEXT-ALIGN: center; LINE-HEIGHT: 32px; DISPLAY: block; HEIGHT: 32px
  45. }
  46. .blk_18 .ScrCont LI A SPAN {
  47. COLOR: #333333; TEXT-DECORATION: none
  48. }
  49. .blk_18 .ScrCont LI A:hover SPAN {
  50. TEXT-DECORATION: underline
  51. }
  52. .blk_18 #List1_1 {
  53. FLOAT: left
  54. }
  55. .blk_18 #List2_1 {
  56. FLOAT: left
  57. }
  58. .blk_18 .LeftBotton {
  59. MARGIN-TOP: 25px; WIDTH: 12px; BACKGROUND: url(img/ui.gif) 30px -406px; FLOAT: left; HEIGHT: 70px
  60. }
  61. .blk_18 .RightBotton {
  62. MARGIN-TOP: 30px; WIDTH: 12px; BACKGROUND: url(img/ui.gif) 13px -406px; FLOAT: right; HEIGHT: 70px
  63. }
  64. .blk_18 .LeftBotton:hover {
  65. BACKGROUND: url(img/ui.gif) 64px -406px
  66. }
  67. .blk_18 .RightBotton:hover {
  68. BACKGROUND: url(img/ui.gif) 47px -406px
  69. }

  70. H2 {
  71. 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
  72. }
  73. UL {
  74. 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
  75. }
  76. LI {
  77. LIST-STYLE-TYPE: none; LIST-STYLE-IMAGE: none
  78. }
复制代码

js代码:
  1. // JavaScript Document

  2. //图片滚动列表 mengjia 070927
  3. var Speed_1 = 10; //速度(毫秒)
  4. var Space_1 = 20; //每次移动(px)
  5. var PageWidth_1 = 184 * 5; //翻页宽度
  6. var interval_1 = 7000; //翻页间隔
  7. var fill_1 = 0; //整体移位
  8. var MoveLock_1 = false;
  9. var MoveTimeObj_1;
  10. var MoveWay_1="right";
  11. var Comp_1 = 0;
  12. var AutoPlayObj_1=null;
  13. function GetObj(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}}
  14. function AutoPlay_1(){clearInterval(AutoPlayObj_1);AutoPlayObj_1=setInterval('ISL_GoDown_1();ISL_StopDown_1();',interval_1)}
  15. 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);}
  16. 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}
  17. AutoPlay_1()}
  18. 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}
  19. GetObj('ISL_Cont_1').scrollLeft-=Space_1}
  20. 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)}
  21. 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}
  22. AutoPlay_1()}
  23. 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}
  24. GetObj('ISL_Cont_1').scrollLeft+=Space_1}
  25. function CompScr_1(){if(Comp_1==0){MoveLock_1=false;return}
  26. 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}}
  27. if(Comp_1<0){if(Comp_1<-TempSpace){Comp_1+=TempSpace;num=TempSpace}else{num=-Comp_1;Comp_1=0}
  28. 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}
  29. GetObj('ISL_Cont_1').scrollLeft+=num;setTimeout('CompScr_1()',TempSpeed)}}
  30. function picrun_ini(){
  31. GetObj("List2_1").innerHTML=GetObj("List1_1").innerHTML;
  32. GetObj('ISL_Cont_1').scrollLeft=fill_1>=0?fill_1:GetObj('List1_1').scrollWidth-Math.abs(fill_1);
  33. GetObj("ISL_Cont_1").onmouseover=function(){clearInterval(AutoPlayObj_1)}
  34. GetObj("ISL_Cont_1").onmouseout=function(){AutoPlay_1()}
  35. AutoPlay_1();
  36. }
  37. function startmarquee(elementID,h,n,speed,delay){
  38. var t = null;
  39. var box = '#' + elementID;
  40. $(box).hover(function(){
  41. clearInterval(t);
  42. }, function(){
  43. t = setInterval(start,delay);
  44. }).trigger('mouseout');
  45. function start(){
  46. $(box).children('ul:first').animate({marginTop: '-='+h},speed,function(){
  47. $(this).css({marginTop:'0'}).find('li').slice(0,n).appendTo(this);
  48. })
  49. }
  50. }
  51. //产品展示滚动图片结束
  52. //-->
复制代码

打包下载:
phpcms首页滚动图片代码.rar (220.69 KB, 下载次数: 453)


全部评论0
回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|管理员之家 ( 苏ICP备2023053177号-2 )

GMT+8, 2025-1-10 20:58 , Processed in 0.210437 second(s), 29 queries .

Powered by Discuz! X3.5

Cpoyright © 2001-2025 Discuz! Team