Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

216
Views
¿Cuál es el código que me permite reproducir y detener la animación del logotipo en html o css?

¿Cuál es el código que me permite reproducir y detener la animación del logotipo en html, css o js?

Estoy tratando de hacer que la animación de mi logotipo se reproduzca cada vez que alguien presiona un botón específico.

Gracias,

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Aquí tiene un ejemplo de un "logotipo" que gira cuando se hace clic en el botón agregando un nombre de clase al logotipo. Cuando la animación haya terminado, se eliminará el nombre de la clase.

 var logo = document.getElementById('logo'); document.querySelector('button').addEventListener('click', e => { logo.classList.add('rotate'); }); logo.addEventListener('animationend', e => { e.target.classList.remove('rotate'); });
 #logo { transform: rotate(0deg); } .rotate { animation: rotate 2s; } @keyframes rotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
 <svg id="logo" viewBox="0 0 2 2" width="100"> <rect width="2" height="2" fill="orange"/> </svg> <button>Rotate</button>

about 4 years ago · Juan Pablo Isaza Report

0

Como mencionó sigurd-mazanti, puede configurar un Click Listener ( addEventListener ) en algunos botones y cada vez que se hace clic en un botón, cambiar entre las clases de animación en el elemento de su logotipo.

 const logo = document.querySelector("img"); document.querySelectorAll("button").forEach((btn) => { let animation = ""; btn.addEventListener("click", function() { switch (btn.id) { case "btn1": animation = "flash"; break; case "btn2": animation = "shake"; break; case "btn3": animation = "beat"; break; } logo.className = animation; }); });
 .flash { animation: flash .7s ease infinite; } @keyframes flash { from { opacity: 1; } 50% { opacity: 0; } to { opacity: 1; } } .shake { animation: shake 0.5s linear infinite; } @keyframes shake { from { transform: rotate(0deg); } 25% { transform: rotate(5deg); } 75% { transform: rotate(-5deg); } to { transform: rotate(0deg); } } .beat { animation: beat 0.3s ease infinite; } @keyframes beat { from { transform: scale(1) } 25% { transform: scale(0.95) } to { transform: scale(1) } }
 <img src="https://source.unsplash.com/6TQdGPcgLZA/640x400" style="display: block; width: 200px;" alt="" /> <div style="margin: 15px;"> <button id="btn1">Flash</button> <button id="btn2">Shake</button> <button id="btn3">Beat</button> </div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!