Set Mouse Wheel To Horizontal Scroll Using Css
I want to design a horizontal page. When I use mouse wheel it just scrolls content vertically. How can I use horizontal scroll by mouse wheel? Does CSS support this property? For
Solution 1:
We can scroll the page horizontally by SHIFT key + scroll through mouse.
Solution 2:
Rotate the container by –90 degrees, then rotate its child element by 90 degrees.
.container {
width: 180px;
height: 600px;
overflow-y: scroll;
transform: rotate(-90deg);
}
.content {
width: 140px;
height: 140px;
margin: 10px;
background-color: #a8a8df;
transform: rotate(90deg);
}
<divclass="container"><divclass="content">Content 1</div><divclass="content">Content 2</div><divclass="content">Content 3</div><divclass="content">Content 4</div><divclass="content">Content 5</div><divclass="content">Content 6</div><divclass="content">Content 7</div></div>
See Pieter Biesemans’ article on CSS Tricks about it; he also lists browser compatibility.
Solution 3:
CSS does not support manipulation of mouse or keyboard inputs; input controls can only be manipulated via JavaScript.
Solution 4:
Microsoft IE 10 has a prefixed property, take a look at -ms-scroll-translation... but just to you know... it is not widely supported yet, but still a good idea :(
Solution 5:
var item = document.getElementById("MAIN");
window.addEventListener("wheel", function (e) {
if (e.deltaY > 0) item.scrollLeft += 100;
else item.scrollLeft -= 100;
});
Where "MAIN"
is your container
Post a Comment for "Set Mouse Wheel To Horizontal Scroll Using Css"