Код: Выделить всё
const buttonRight = document.getElementById('slideRight');
const buttonLeft = document.getElementById('slideLeft');
buttonRight.onclick = function () {
document.getElementById('container').scrollLeft += 150;
};
buttonLeft.onclick = function () {
document.getElementById('container').scrollLeft -= 150;
};< /code>
#container {
width: 145px;
height: 100px;
border: 1px solid #ccc;
overflow-x: scroll;
}
#content {
width: 250px;
background-color: #ccc;
}< /code>
Click the buttons to slide horizontally!
Slide left
Slide right
Подробнее здесь: https://stackoverflow.com/questions/623 ... t-smoothly