そのままコピーしたら、ほとんど修正せずに使えます!ご質問がございましたら、ご相談ください コードをコピー コードは次のとおりです: 滚アニメーション代<br>*{ margin:0;パディング:0;}<br>ul,li{ list-style:none;}<br>.left_1{ width:500px;高さ:100ピクセル; margin:0 auto;}<br>.left_1 ul{}<br>.left_1 li{ float:left;幅:120ピクセル;高さ:100ピクセル;行の高さ:100ピクセル; text-align:center;}<br>.left_1 p{ width:50px;彼<br> 100ピクセル; line-height:100px;}<br>.left_1_i div{ width:100px;高さ:100ピクセル;行の高さ:100ピクセル;ボーダー:1px ソリッド #e5e5e5;マージン左:10px; padding-left:10px;}<br><br>functionscrollSZ(con_id,speed,direct){<br> var con,items,heightHalf ,heightAll;<br> var timer;<br> speed = parseInt(speed);//获取設置の速度パラメータ<br> con = document.getElementById(con_id);<br> con.style.overflow = "hidden" ;<br> if(direct == "top"){<br> direct = "top";<br> }else if(direct == "bottom"){<br> direct = "bottom";<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 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.getComputedStyle(items[i],null)["marginTop"];<BR> numBottom = document.defaultView.getComputedStyle(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> timer = setInterval(_scrollBottom,speed); <br> }else if(direct == "top"){<br> timer = setInterval(_scrollTop,speed);<br> }<br> con.onmouseover = function(){<br> if(timer){ <br> clearInterval(timer);<br> timer = null;<br> }<br> };<br> con.onmouseout = function(){<br> if(!timer){<br> if(direct == "top"){<br> timer = setInterval(_scrollTop,speed);<br> }else if(direct == "bottom"){<br> timer = 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>functionscrollSP(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 = items[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 = items[i].currentStyle["marginRight"];<BR> }else{<BR> items[i].style.cssFloat = "left";<BR> numLeft = document.defaultView.getComputedStyle(items[i] ,null)["marginLeft"];<BR> numRight = document.defaultView.getComputedStyle(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 = items[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> timer = setInterval(_scrollLeft,speed);<BR> }else if(direct == "right"){<BR> con.scrollLeft = widthHalf;<BR> timer = setInterval(_scrollRight,speed);<BR> }<BR> con.onmouseover = function(){<BR> if(timer){<BR> clearInterval(timer);<BR> timer = null;<BR> }<BR> }<BR> con.onmouseout = function(){<BR> if(direct == "left"){<BR> timer = setInterval(_scrollLeft,speed);<BR> }else{<BR> timer = 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>