<div class="slider">
<div id="comparison">
<figure>
<div id="divisor"></div>
</figure>
</div>
<div class="slider__menu">
<button class="slider__menu-button button__min">Было</button>
<input class="slider__menu-range" type="range" min="0" max="100" value="50" id="slider" oninput="moveDivisor()">
<button class="slider__menu-button button__plus">Стало</button>
</div>
</div>
</div>
div#comparison {
width: 768px;
height: 510px;
margin: 0 auto;
max-width: 650px;
max-height: 517px;
overflow: hidden;
margin-bottom: 50px;
}
div#comparison figure {
background-image: url(https://i.ibb.co/YbjFdpW/after-desktop.jpg);
background-size: cover;
background-repeat: no-repeat;
position: relative;
font-size: 0;
width: 100%;
height: 100%;
margin: 0;
}
div#comparison figure > img {
position: relative;
width: 100%;
}
div#comparison figure div {
background-image: url(https://i.ibb.co/5cZyrBb/before-desktop.jpg);
background-size: cover;
position: absolute;
width: 50%;
overflow: hidden;
bottom: 0;
height: 100%;
}
.slider__menu {
width: 575px;
margin: 0 auto;
}
.slider__menu-range {
appearance: none;
appearance: none;
appearance: none;
position: relative;
height: 6px;
width: 425px;
border-radius: 4px;
background-color: #dcdcdc;
margin-bottom: 100px;
}
.slider__menu-range:focus {
outline: none;
}
.slider__menu-range:active {
outline: none;
}
.slider__menu-range-webkit-::range-track {
appearance: none;
appearance: none;
appearance: none;
height: 6px;
width: 425px;
background-color: #dcdcdc;
position: relative;
outline: none;
}
.slider__menu-range::active {
border: none;
outline: none;
}
.slider__menu-range::slider-thumb {
appearance: none;
position: relative;
width: 32px;
height: 32px;
background-color: #fff;
border: 2px solid #dcdcdc;
border-radius: 50px;
cursor: pointer;
background-image: radial-gradient(at center center, #68b738, #68b738 4px, white 4px);
}
.slider__menu-range::slider-thumb:hover {
box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.25);
box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.25);
}
.slider__menu-range::slider-thumb:active {
border-color: #68b738;
}
.before-after__range::after {
content: '';
position: absolute;
top: -1px;
left: 209px;
width: 8px;
height: 8px;
border-radius: 10px;
background-color: #68b738;
}
.slider__menu-range::range-thumb {
appearance: none;
width: 32px;
height: 32px;
background: #fff;
border: 1px solid #dcdcdc;
border-radius: 50px;
}
.slider__menu-button {
padding: 0;
font-family: 'Oswald';
background-color: transparent;
border: none;
font-size: 20px;
font-weight: 400;
border-bottom: 1px dotted #bebebe;
cursor: pointer;
}
.slider__menu-button:hover {
border-bottom: 1px solid #bebebe;
}
.slider__menu-button:active {
border: none;
}
.slider__menu-button:focus {
outline: none;
}
var divisor = document.getElementById("divisor"),
slider =
document.getElementById("slider");
function moveDivisor() {
divisor.style.width = slider.value+"%";
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.