HTML markup:
<div class="big">
long width text
</div>
CSS rule:
.big{
height:200px;
background: red;
}
How to scroll horizontal Only BIG div on mouse wheel http://jsfiddle.net/cxD55/
HTML markup:
<div class="big">
long width text
</div>
CSS rule:
.big{
height:200px;
background: red;
}
How to scroll horizontal Only BIG div on mouse wheel http://jsfiddle.net/cxD55/
Set the overflow-x CSS style but leave the overflow-y style set to visible.
Here is the solution:
Html
<div class="big">
long text here
</div>
CSS
.big {
height: 200px;
overflow: hidden;
width:6000px;
}
JS
(function () {
function scrollHorizontally(e) {
e = window.event || e;
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
document.body.scrollLeft -= (delta * 40); // Multiplied by 40
e.preventDefault();
}
if (window.addEventListener) {
// IE9, Chrome, Safari, Opera
window.addEventListener("mousewheel", scrollHorizontally, false);
// Firefox
window.addEventListener("DOMMouseScroll", scrollHorizontally, false);
} else {
// IE 6/7/8
window.attachEvent("onmousewheel", scrollHorizontally);
}
})();
Change width
according to your need.