Unique styling not found in CSS
div {
scroll-direction: horizontal;
}
This could have been useful, but fear not, There is a solution
You can even create your own.
Simple with JavaScript
const container = document.getElementById("container");
// where "container" is the id of the container
container.addEventListener("wheel", function (e) {
if (e.deltaY > 0) {
container.scrollLeft += 100;
e.preventDefault();
// prevenDefault() will help avoid vertical scroll
}
else {
container.scrollLeft -= 100;
e.preventDefault();
}
});
// This method works perfectly
If you prefer using CSS, here is how you can create a container, rotate it, rotate the items, and enable scrolling.
The process:
- Create the
container
element and apply CSS styles:
<!------ HTML ------>
<div class="container">
<div>item 1</div>
<div>item 2</div>
<div>item 3</div>
<div>item 4</div>
<div>item 5</div>
<div>item 6</div>
<div>item 7</div>
<div>item 8</div>
</div>
/** CSS **/
.container {
width: 100px;
height: 300px;
overflow-y: auto;
overflow-x: hidden;
transform: rotate(-90deg);
transform-origin: right top;
transform:rotate(-90deg) translateY(-100px);
}
.container > div {
width: 100px;
height: 100px;
transform: rotate(90deg);
transform-origin: right top;
}
Hope this information is helpful!