<div class="main">
<div class="div">
	<div class="dot"></div>
	<div class="bar">
	</div>
</div>
</div>
body {
  box-sizing: border-box;
  padding: 2rem;
}
.main {
  height: 100vh;
  display: grid;
  justify-content: center;
  align-items: center;
  background-color: #282828;
}

.div {
  display: flex;
  background: #404040;
  height: 10px;
  width: 400px;
  position: relative;
  opacity: 1;
  border-radius: 2px;
}

.bar {
  width: 100%;
  height: 100%;
  z-index: 1;
  position: absolute;
  content: "";
  top: 0;
  transition: all 0.4s ease-out;
}

.dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  z-index: 120;
  margin-left: -2px;
  margin-top: -3px;
  left: 0;
  position: absolute;
  content: "";
  top: 0;
  cursor: pointer;
  background-color: rgb(253, 253, 253);
  transition: all 0.4s ease-out;
}

.dot::before {
  width: 3px;
  height: 40px;
  content: "";
  z-index: 0;
  top: 14px;
  left: 5px;
  position: absolute;
  background-color: rgb(0, 0, 0);
  animation: move 1s both;
  animation-iteration-count: infinite;
  animation-delay: 1s;
}

@keyframes move {
  0% {
    opacity: 0.2;
    transform: translateX(1%);
    background: rgb(60, 255, 0);
  }
  50% {
    opacity: 0.8;
    transform: translateY(10%);
    background: #ccc;
  }

  100% {
    opacity: 1;
    background: rgb(255, 255, 255);
    transform: translateY(100%);
  }
}
var div = document.querySelector(".div");
var bar = document.querySelector(".bar");
var dot = document.querySelector(".dot");
let move;

div.addEventListener("mousedown", e => {
  let percentage;
  move = true;
  let j = e.clientX - div.offsetLeft;

  percentage = (100 * j) / div.clientWidth;
  console.log(percentage);

  bar.style.backgroundColor = "#00C24B";

  if (percentage > 100) {
    percentage = 100;
  }
  if (percentage < 0) {
    percentage = 0;
  }
  bar.style.width = percentage + "%";
  dot.style.left = percentage + "%";
});

document.addEventListener("mousemove", hush);

function hush(e) {
  if (move) {
    let percentage;

    let j = e.clientX - div.offsetLeft;

    percentage = (100 * j) / div.clientWidth;
    console.log(percentage);
 

    
    bar.style.backgroundColor = "#00C24B";

    if (percentage > 100) {
      percentage = 100;
    }

    if (percentage < 0) {
      percentage = 0;
    }
    bar.style.width = percentage + "%";
    dot.style.left = percentage + "%";

    console.log(bar.style.width + "bar", " dot" + dot.style.left);
  }
}

document.addEventListener("mouseup", e => {
  move = false;
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.