romveld,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.bottom-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 12px;
margin-bottom: 12px;
}
#range {
-webkit-appearance: none;
width: 20vw;
height: 2px;
padding: 0;
border-radius: 1px;
border: none;
background-image: linear-gradient(to right, rgb(223, 149, 52) 0%, rgb(223, 149, 52) 0%, rgb(234, 236, 238) 0%, rgb(234, 236, 238) 100%);
outline: none;
margin: 10px auto;
display: block;
}
#range:focus {
outline: none;
}
#range:hover {
opacity: 1;
}
#range::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
border-radius: 50%;
background-color: rgb(223, 149, 52);
cursor: pointer;
}
#range::-moz-range-thumb,
#range::-ms-thumb {
width: 16px;
height: 16px;
border-radius: 50%;
background-color: rgb(223, 149, 52);
cursor: pointer;
}
#range::-ms-fill-lower,
#range::-moz-range-progress {
background-color: #ffdd2d;
}
#range::-ms-fill-upper,
#range::-moz-range-track {
background-color: #eaecee;
}
.carousel {
width: 400px;
height: 100px;
overflow: hidden;
margin: 10px auto;
}
.content {
display: flex;
}
.content img {
flex-basis: 300px;
transform: translateX();
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function() {
var values = [4, 6, 12];
var range = document.getElementById('range');
function getPersent(value, max) {
return value / max * 100 | 0;
}
function setBackground(percent) {
range.style.backgroundImage = `linear-gradient(to right, rgb(223, 149, 52) 0%, rgb(223, 149, 52) ${percent}%, rgb(234, 236, 238) ${percent}%, rgb(234, 236, 238) 100%)`
document.querySelectorAll('.content').forEach(el => {
let {
clientWidth: a,
scrollWidth: b
} = el;
el.style.transform = `translateX(${(a-b)/100 * percent}px)`
})
}
range.addEventListener('mousemove', function() {
var percent = getPersent(this.value, this.max);
setBackground(percent)
});
});
</script>
</head>
<body>
<div class="carousel">
<div class="content">
<img src="https://picsum.photos/300/100?1">
<img src="https://picsum.photos/300/100?2">
<img src="https://picsum.photos/300/100?3">
<img src="https://picsum.photos/300/100?4">
<img src="https://picsum.photos/300/100?5">
<img src="https://picsum.photos/300/100?6">
<img src="https://picsum.photos/300/100?7">
<img src="https://picsum.photos/300/100?8">
<img src="https://picsum.photos/300/100?9">
</div>
</div>
<input class="slider" id="range" type="range" min="0" max="1" value="0" step=".01">
<div class="carousel">
<div class="content">
<img src="https://picsum.photos/300/100?10">
<img src="https://picsum.photos/300/100?11">
<img src="https://picsum.photos/300/100?12">
</div>
</div>
<div class="carousel">
<div class="content">
<img src="https://picsum.photos/300/100?13">
<img src="https://picsum.photos/300/100?14">
</div>
</div>
</body>
</html>