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

250
Vistas
Why doesnt transition work in created element(JS DOM,CSS)?

If you click on "some text" in example, the element is created and than it should move 100px up with transition. I am not able to do it with js DOM or css class switch. I miss something, but I am not able to find out belly of the beast. Maybe typo? Or some principle?

other types of solution are also welcome..

thank you!

var ul = document.getElementById('timeline');

ul.addEventListener('click', function(e) {
  if (e.target.tagName === 'LI') {
    let star = document.createElement("div");
    star.className = "star";

    e.target.insertBefore(star, e.target.getElementsByTagName("time")[0]);
    star.style.transform = "translateY(-100px)";
    star.style.transition = "all 2s linear";
  }
});
.wrap-timeline {
  position: relative;
  left: 100px;
}

.wrap-timeline ul {
  list-style-type: none;
}

.wrap-timeline ul li {
  margin: 100px 50px;
}

.wrap-timeline ul li time {
  position: absolute;
  left: -100px;
}

.wrap-timeline ul li .star {
  position: absolute;
  left: 5px;
  width: 50px;
  height: 20px;
  z-index: 2;
  background-color: blue;
}

time::before {
  content: "";
  background-color: red;
  width: 65px;
  height: 35px;
  position: absolute;
  left: 100px;
  top: -10px;
  z-index: 3;
}
<div class="wrap-timeline">

  <ul id="timeline">
    <li><time datetime="XXXX-XX">xxxx</time> some text</li>
  </ul>
</div>

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