I need help replacing the horizontal scrollbar with arrow buttons to scroll through images (not the entire page).
This is the code I tried:
.scroll-images::-webkit-scrollbar{
-webkit-appearance: none;
}
However, the scrollbar is still visible. Here is the complete code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Horizontal Scroll Bar</title>
<style>
*{
margin: 0px;
padding: 0px;
box-sizing: border-box;
background-color: black;
}
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
width: 100%;
background-color: black;
}
.main-scroll-div{
width: 90%;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
border: 2px solid red;
}
.cover{
position: relative;
width: 90%;
height: 50%;
}
.scroll-images{
width: 100%;
height: auto;
display: flex;
justify-content: left;
align-items: center;
overflow: auto;
position: relative;
scroll-behavior: smooth;
}
.child{
min-width: 600px;
height: 450px;
margin: 1px 10px;
cursor: pointer;
border: 1px solid white;
overflow: hidden;
}
.child-img{
width: 100%;
height: 100%;
}
.scroll-images::-webkit-scrollbar{
-webkit-appearance: none;
}
.icon{
color: green;
background-color: black;
font-size: 50px;
outline: none;
border: none;
padding: opx 20px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="main-scroll-div">
<div>
<button class ="icon"> <i class="left"></i></button>
</div>
<div class ="cover">
<div class="scroll-images">
<div class="child"><img class="child-img" src="imges/1.jpg" alt="image"></div>
<div class="child"><img class="child-img" src="imges/2.jpg" alt="image"></div>
<div class="child"><img class="child-img" src="imges/3.jpg" alt="image"></div>
<div class="child"><img class="child-img" src="imges/4.jpg" alt="image"></div>
</div>
</div>
<div>
<button class ="icon"> <i class="left"></i></button>
</div>
</div>
</body>
</html>
I also attempted using display: none
and appearance: none
, but neither worked.