Как мне сделать чтобы по нажатию на кнопки сайт листался при параметре overflow: hidden; вот код страницы:
const slides = document.querySelectorAll('.sidebar-item')
const up = document.querySelector('#up')
const down = document.querySelector('#down')
up.addEventListener('click', RGB)
down.addEventListener('click', RGB)
RGB()
function gRG() {
let deg = Math.floor(Math.random() * 360);
let a = Math.floor(Math.random() * 255);
let b = Math.floor(Math.random() * 255);
let c = Math.floor(Math.random() * 255);
let d = Math.floor(Math.random() * 255);
let e = Math.floor(Math.random() * 255);
let f = Math.floor(Math.random() * 255);
return `linear-gradient(${deg}deg, rgba(${a},${b},${c},1) 0%, rgba(${e},${f},${d},1) 100%)`
}
function RGB() {
for (let i = 0; i < 4; i++) {
let gradient = gRG()
slides[i].style.background = gradient;
}
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
height: 100vh;
}
.container {
position: relative;
width: 100vw;
height: 100vh;
}
.sidebar {
height: 100%;
width: 40%;
position: absolute;
top: 0;
left: 0;
}
.sidebar>div {
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.sidebar h1 {
font-size: 40px;
margin-bottom: 10px;
margin-top: -30px;
}
.main-slide {
height: 100%;
width: 60%;
position: absolute;
top: 0;
left: 40%;
}
.main-slide>div {
background-repeat: no-repeat;
background-size: cover;
background-position: center;
width: 100%;
height: 100%;
}
button {
background-color: #fff;
border: none;
color: #AAA;
cursor: pointer;
font-size: 16px;
padding: 15px;
}
button:hover {
color: #222;
}
button:focus {
outline: none;
}
.container .controls button {
position: absolute;
left: 40%;
top: 50%;
z-index: 100;
padding: 5px;
border: none;
}
.down-button {
transform: translateX(-100%);
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
.up-button {
transform: translateY(-100%);
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./style.css">
<title>Slider</title>
</head>
<body>
<div class="container">
<div class="sidebar">
<div class="sidebar-item">
<h1>СЛАЙД 1</h1>
<p>Lorem ipsum dolor sit amet.</p>
</div>
<div class="sidebar-item">
<h1>СЛАЙД 2</h1>
<p>Lorem ipsum dolor sit amet.</p>
</div>
<div class="sidebar-item">
<h1>СЛАЙД 3</h1>
<p>Lorem ipsum dolor sit amet.</p>
</div>
</div>
<div class="main-slide">
<div style="background-image: url(https://images.unsplash.com/photo-1677446320988-e65803c103f0?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1887&q=80);"></div>
<div style="background-image: url(https://images.unsplash.com/photo-1677503311210-fa140a7141da?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1887&q=80);"></div>
<div style="background-image: url(https://images.unsplash.com/photo-1677021276420-76bb9d8deb0a?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1887&q=80);"></div>
</div>
<div class="controls">
<button class="down-button" id="down">
<i class="fas fa-arrow-down"></i>
</button>
<button class="up-button" id="up">
<i class="fas fa-arrow-up"></i>
</button>
</div>
</div>
<script src="./main.js"></script>
</body>
</html>
Источник: Stack Overflow на русском