JSFiddle - React, Tailwind, and code Playground
HTML
<div class="wrap-X">
<div class="div-X"></div>
</div>
<div class="wrap-Y">
<div class="div-Y"></div>
</div>
CSS
body {
display: flex;
height: 100vh;
margin: 0;
align-items: center;
justify-content: space-around;
}
.wrap-X {
width: 150px;
height: 75px;
overflow: auto hidden;
}
.div-X {
height: 100%;
width: 500%;
background: linear-gradient(90deg, black 50%, crimson 50%);
background-size: 20px 100%;
}
.wrap-Y {
width: 75px;
height: 150px;
overflow: hidden auto;
}
.div-Y {
height: 500%;
width: 100%;
background: linear-gradient(0deg, black 50%, crimson 50%);
background-size: 100% 20px;
}
JavaScript
var x = 0;
document.querySelector('.wrap-X').addEventListener('wheel', function(e) {
x += e.deltaY / 2;
e.preventDefault();
this.scrollTo({
left: x,
behavior: 'smooth'
});
});