그대로 복사하시면 거의 수정 없이 사용 가능해요! 궁금한 점이 있으면 토론해 보세요 코드 복사 코드는 다음과 같습니다. 滚动代码<br>*{ margin:0; 패딩:0;}<br>ul,li{ 목록 스타일:none;}<br>.left_1{ 너비:500px; 높이:100px; margin:0 auto;}<br>.left_1 ul{}<br>.left_1 li{ float:left; 너비:120px; 높이:100px; 줄 높이:100px; 텍스트 정렬:중심;}<br>.left_1 p{ 너비:50px; 그<br> 100px; line-height:100px;}<br>.left_1_i div{ 너비:100px; 높이:100px; 줄 높이:100px; 테두리:1px 솔리드 #e5e5e5; 여백-왼쪽:10px; padding-left:10px;}<br><br>function scrollSZ(con_id,speed,direct){<br> var con,items,heightHalf ,heightAll;<br> var 타이머;<br> speed = parseInt(speed);//获取设置的速島参数<br> con = document.getElementById(con_id);<br> con.style.overflow = "hidden" ;<br> if(direct == "상단"){<br> direct = "상단";<br> }else if(direct == "하단"){<br> direct = "하단";<br> }else{<br> direct = "top";<br> }<br><br> con.innerHTML =con.innerHTML;<br> con.innerHTML =con.innerHTML;<br> items = getChildNodes(con) ;<br> if(items.length < 1){<BR> return;<BR> }<BR> heightAll = 0;<BR> for(var i=0;i<items.length;i ){<BR> var numTop,numBottom;<BR> if (!!window.ActiveXObject){<BR> numTop = items[i].currentStyle["marginTop"];<BR> numBottom = items[i].currentStyle["marginBottom "];<BR> }else{<BR> numTop = document.defaultView.getCompulatedStyle(items[i],null)["marginTop"];<BR> numBottom = document.defaultView.getCompulatedStyle(items[i],null )["marginBottom"];<BR> }<BR> numTop = parseInt(numTop);<BR> numBottom =parseInt(numBottom);<BR> numTop = numBottom;<BR> if(numTop >0){<br> heightAll = numTop;<br> }<br> heightAll = items[i].offsetHeight;<br> }<br> heightHalf = heightAll/2;<br> if(direct == "bottom"){<br> con.scrollTop = heightHalf;<br> 타이머 = setInterval(_scrollBottom,speed); <br> }else if(direct == "top"){<br> 타이머 = setInterval(_scrollTop,speed);<br> }<br> con.onmouseover = function(){<br> if(타이머){ <br> clearInterval(timer);<br> 타이머 = null;<br> }<br> };<br> con.onmouseout = function(){<br> if(!timer){<br> if(direct == "top"){<br> 타이머 = setInterval(_scrollTop,speed);<br> }else if(direct == "bottom"){<br> 타이머 = setInterval(_scrollBottom,speed);<br> } <br><br> }<br> };<br> function _scrollTop(){<br> if(con.scrollTop < heightHalf){<BR> con.scrollTop = 2;<BR> }else{<BR> con.scrollTop = 0;<BR> }<BR> }<BR> function _scrollBottom(){<BR> if(con.scrollTop > 0){<br> con.scrollTop -= 2;<br> } else{<br> con.scrollTop = heightHalf;<br> }<br> }<br>}<br>function scrollSP(con_id,speed,direct){<br> var con,innerCon,timer,items,widthAll, widthHalf;<br> speed = parseInt(speed);<br> con = document.getElementById(con_id);<br> con.style.overflow = "hidden";<br> items = getChildNodes(con);<br> if(items.length == 1){<br> innerCon = 항목[0];<br> }else{<br> return;<br> }<br> innerCon.innerHTML = innerCon.innerHTML;<br> innerCon .innerHTML = innerCon.innerHTML;<br> items = getChildNodes(innerCon);<br> if(items.length<1){<BR> return;<BR> }<BR> widthAll = 0;<BR> for( var i=0;i<items.length;i ){<br><br> }<br><br> for(var i=0;i<items.length;i ){<BR> var numLeft,numRight ;<BR> if (!!window.ActiveXObject){<BR> items[i].style.styleFloat = "left";<BR> numLeft = items[i].currentStyle["marginLeft"];<BR> numRight = 항목[i].currentStyle["marginRight"];<BR> }else{<BR> 항목[i].style.cssFloat = "왼쪽";<BR> numLeft = document.defaultView.getCompulatedStyle(items[i] ,null)["marginLeft"];<BR> numRight = document.defaultView.getCompulatedStyle(items[i],null)["marginRight"];<BR> }<BR> numLeft = parseInt(numLeft);<BR> numRight = parseInt(numRight);<BR> numLeft = numRight;<BR> if(numLeft>0){<br> widthAll = numLeft;<br> }<br> widthAll = 항목[i].offsetWidth;<br> }<br> widthHalf = widthAll/2;<br> innerCon.style.width = widthAll "px";<br> if(direct == "left"){<br> direct = "left";<br> }else if(direct == "오른쪽"){<br> direct = "오른쪽";<br> }else{<br> direct = "왼쪽"<br> }<br> if(direct == "왼쪽"){ <br> 타이머 = setInterval(_scrollLeft,speed);<br> }else if(direct == "right"){<br> con.scrollLeft = widthHalf;<br> 타이머 = setInterval(_scrollRight,speed);<br> }<br> con.onmouseover = function(){<br> if(타이머){<br> clearInterval(timer);<br> 타이머 = null;<br> }<br> }<br> con.onmouseout = function(){<br> if(direct == "left"){<br> 타이머 = setInterval(_scrollLeft,speed);<br> }else{<br> 타이머 = setInterval(_scrollRight,speed);<br> }<br> }<br> function _scrollLeft(){<br><br> if(con.scrollLeft<widthHalf){<BR> con.scrollLeft = 2;<BR> }else{<BR> con.scrollLeft = 0;<BR> }<BR> }<BR> function _scrollRight(){<BR> if(con.scrollLeft>0){<br> con.scrollLeft -= 2;<br> }else{<br> con.scrollLeft = widthHalf;<br> }<br> }<br>}<br>function getChildNodes(obj){//获取元素子节点<br> var childList,list;<br> childList = new Array() ;<br> list = obj.childNodes;<br> for(var i=0;i<list.length;i ){<BR> if(list[i].nodeType == 1)<BR> childList[childList .length] = list[i];<BR> }<BR> return childList;<BR>}<BR> 1 < ;p>2 3 4 b scrollSP("left_1",10,"right");< /script><br></body><br></html></p> <p> </p> </div>