Glassmorphism Range Slider with HTML , CSS & Javascript

Web Design & Web Development

Demo

Sponsored links

 

Code

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Glassmorphism Range Slider</title>
    <link rel="stylesheet" type="text/css" href="https://demo.plantpot.works/assets/css/normalize.css">
    <link rel="stylesheet" href="https://use.typekit.net/opg3wle.css">
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <div id="container">
      <div class="box">
        <input id="slider" class="slider" type="range" min="0" max="100" value="50">
        <div id="value" class="value"></div>
        <div id="bg" class="bg"></div>
      </div>
    </div>
  </body>
</html>

CSS

@charset "utf-8";
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
}
body {
  background-color: #000;
  font-family: futura-pt, sans-serif;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}
#container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
  height: 100vh;
}
.box {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
  max-width: 280px;
  padding: 20px 10px;
  border-radius: 5px;
  background-color: rgba(255, 255, 255, .1);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
}
.slider {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 100%;
  height: 10px;
  border: none;
  border-radius: 5px;
  background-color: rgba(255, 255, 255, .1);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
  cursor: pointer;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background-color: #33ff00;
}
.value {
  position: absolute;
  top: 20px;
  left: 10px;
  z-index: 1;
  width: 125px;
  height: 10px;
  border-radius: 5px 0 0 5px;
  background-color: #33ff00;
}
.bg {
  position: absolute;
  top: 20px;
  left: 10px;
  z-index: 0;
  width: 125px;
  height: 10px;
  border-radius: 5px 0 0 5px;
  background-color: #33ff00;
  filter: blur(5px);
}

Javascript

var slider = document.getElementById("slider");
var val = document.getElementById("value");
var bg = document.getElementById("bg");
slider.oninput = function() {
  var active = 250 * (this.value / 100);
  val.style.width = active + 'px';
  bg.style.width = active + 'px';
}