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

108
Vistas
Agregar animación a paneles horizontales alternos

Tengo un fragmento de trabajo para dos paneles horizontales que se alternan al hacer clic en el divisor. Necesito agregar una animación simple al divisor para que se mueva de un lado a otro en medio segundo. ¿Cómo puedo conseguir esto?

 function changeThis() { var getF = document.getElementById("first"); var getS = document.getElementById("second"); if(getF.style.width == "0%") { getF.style.width="100%"; getS.style.width="0%"; } else { getF.style.width="0%"; getS.style.width="100%"; } }
 .splitter { width: 100%; height: 100px; display: flex; } #separator { cursor: pointer; background-color: #aaa; background-repeat: no-repeat; background-position: center; width: 10px; height: 100%; /* Prevent the browser's built-in drag from interfering */ -moz-user-select: none; -ms-user-select: none; user-select: none; } #first { background-color: #dde; width: 100%; height: 100%; min-width: 10px; } #second { background-color: #eee; width: 0%; height: 100%; min-width: 10px; }
 <div class="splitter"> <div id="first"></div> <div id="separator" onclick="changeThis()"></div> <div id="second" ></div> </div>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Puedes agregar transition css

 function changeThis() { var getF = document.getElementById("first"); var getS = document.getElementById("second"); if(getF.style.width == "0%") { getF.style.width="100%"; getS.style.width="0%"; } else { getF.style.width="0%"; getS.style.width="100%"; } }
 .splitter { width: 100%; height: 100px; display: flex; } #separator { cursor: pointer; background-color: #aaa; background-repeat: no-repeat; background-position: center; width: 10px; height: 100%; /* Prevent the browser's built-in drag from interfering */ -moz-user-select: none; -ms-user-select: none; user-select: none; } #first { background-color: #dde; width: 100%; height: 100%; min-width: 10px; /** add animation */ transition: .5s width linear; } #second { background-color: #eee; width: 0%; height: 100%; min-width: 10px; /** add animation */ transition: .5s width linear; }
 <div class="splitter"> <div id="first"></div> <div id="separator" onclick="changeThis()"></div> <div id="second" ></div> </div>

about 4 years ago · Juan Pablo Isaza Denunciar
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