Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
Make a progress bar inside a button

document.querySelector('button[id="But_wood"]').addEventListener('click', function() {
    this.classList.add("active");
    setTimeout(()=>{
        this.classList.remove("active");
    },2000);
});
.Collect {
  background: #fff;
  border: 1px solid #000000;
  border-radius: 10px;
  width: 120px;
  height: 30px;
  color: #000000;
  display: inline;
  font: normal normal 16px/25px "alegreya", serif;
  text-align: center;
}

.Collect.active {
  background: lime;
}

.Collect.active::before {
  animation: 2s slidein linear;
  content: "";
  position: absolute;
  height: 5px;
  width: 120px;
  background: #fa237d;
  border-radius: 5px;
}

@keyframes slidein {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}
<button class="Collect" id="But_wood">Pick wood</button>

I want to have a progress bar running inside a button when the user clic on it. Despite several tweaking of the CSS, none of them made it work and no similar post has given me an answer either...

Despite several tweaking of the CSS, none of them made it work and no similar post has given me an answer either...

I would like for the progress bar to be inside the button, under the text. On a side note, I didn't manage to make it run from left to right, but only expending on both side at the same time, how can I change that too ?

https://jsfiddle.net/dmv0obpu/57/

Thank you !

html :

<button class="Collect" id="But_wood">Pick wood</button>

CSS :

.Collect {
  background: #fff;
  border: 1px solid #000000;
  border-radius: 10px;
  width: 120px;
  height: 30px;
  color: #000000;
  display: inline;
  font: normal normal 16px/25px "alegreya", serif;
  text-align: center;
}

.Collect.active {
  background: lime;
}

.Collect.active::before {
  animation: 2s slidein linear;
  content: "";
  position: absolute;
  height: 5px;
  width: 120px;
  background: #fa237d;
  border-radius: 5px;
}

@keyframes slidein {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}

JS :

document.querySelector('button[id="But_wood"]').addEventListener('click', function() {
    this.classList.add("active");
    setTimeout(()=>{
        this.classList.remove("active");
    },2000);
});
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda