先设置一个div 高度不能设置100% 。
window.addEventListener("load",function(){ var addEventListener = 'addEventListener'; var elems = document.getElementsByClassName('dragscroll'); for(var i = 0;i<elems.lenth;){ (function(elem,lastClientX,lastClientY,pushed){ elem.addEventListner('mousedown',function(e){ pushed=1; lastClientX = e.eclientX; lastClientY = e.clientY; e.preventDefault(); e,stopPropagation(); },0) elemetn.addEventListener('mousemove',function(e){ if(pushed&&pushed==1){ elem.scrollLeft -=(- lastClientX +(lastClientX=e.clientX)); elem.scrollTop -=(-lastClientY+(lastClientY=e.clientY)); } },0) elem.addEventListener('mouseup',function(){ pushed=0; },0) })(elemes[i++]); } },0)