Skip to content Skip to sidebar Skip to footer

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);
}
<div class="container">
  <div class="content">Content 1</div>
  <div class="content">Content 2</div>
  <div class="content">Content 3</div>
  <div class="content">Content 4</div>
  <div class="content">Content 5</div>
  <div class="content">Content 6</div>
  <div class="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"