Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 example any thing like this:

mouse-wheel:horizontal;

I dont want jQuery solutions.

like image 396
user2586454 Avatar asked Aug 28 '13 07:08

user2586454


People also ask

How do I make my mouse scroll horizontally in CSS?

We can scroll the page horizontally by SHIFT key + scroll through mouse.

How can I scroll horizontally with my regular mouse?

If you wish to make your mouse scroll horizontally Press SHIFT and then use the Middle mouse scroll wheel. This works if the page is large enough to be scrolled horizontally. You could see a scroll bar at the bottom. You could also press the middle mouse button once.

How do I make my scroll bar horizontal?

For horizontal scrollable bar use the x and y-axis. Set the overflow-y: hidden; and overflow-x: auto; that will automatically hide the vertical scroll bar and present only the horizontal scrollbar. The white-space: nowrap; property is used to wrap text in a single line.


2 Answers

We can scroll the page horizontally by SHIFT key + scroll through mouse.

like image 87
panwar Avatar answered Sep 28 '22 05:09

panwar


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

like image 25
Calvin Guillot Avatar answered Sep 28 '22 06:09

Calvin Guillot