日期:2014-05-16 浏览次数:20365 次
<div id="out_div" style="border: 1px solid #ddd;height: 300px;width:99%;overflow: hidden;">
<div style="width:6000px;height:300px;background: url('http://avatar.profile.csdn.net/3/2/D/1_nojobs.jpg')">
</div>
</div>
<script type="text/javascript">
function scrollFunc(e) {
var direct = 0,i = id.scrollLeft;
e = e
------解决方案--------------------
window.event;
if (e.wheelDelta) {
direct = e.wheelDelta;
} else if (e.detail) {
direct = e.detail;
}
if (direct < 0) {
i +=speed;
} else {
i -=speed;
}
id.scrollLeft=i;
//$("#out_div").stop().animate({scrollLeft:t},"slow");如果用jquery就在此做动画,滚动就不会生硬。
}
var id=document.getElementById("out_div");
var speed=40;//调整速度
if (document.addEventListener) {
id.addEventListener('DOMMouseScroll', scrollFunc, false);//Firefox
}
id.onmousewheel = scrollFunc; //IE
</script>