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

241
Views
¿Cómo puedo animar esta imagen de diamante para que parezca que el diamante 3d gira hacia abajo?

Quiero animar las imágenes de este diamante de tal manera que parezca que un diamante real está girando. Como un diamante 3d gira hacia abajo. Por favor ayúdame significa mucho. Gracias.

lo que intento

la animación se utiliza en la segunda sección del sitio web

 <section class="relative flex items-center justify-center w-screen h-screen bg-gray-600"> <div class="absolute w-40 h-20 top-28" > <div class=""> <img class="ml-3 w-36 diamond_animtion" src="fake/diamond.png" alt=""> </div> <img class="absolute ml-12 top-14" style="width: 70px;" src="fake/Prong.png" alt=""> </div> <img class="w-96 h-96" src="fake/ring.png" alt=""> </section>

¿Cómo puedo reducir la velocidad de la animación?

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

0

Puede hacer el truco usando el desbordamiento de css y la posición de fondo, luego use JS para hacer que se mueva.

 let height = 0, steps = 0; const animation = setInterval((function() { height += 290.35, document.getElementById("diamond").style.backgroundPosition = `0px -${height}px`, 18 == steps++ && clearInterval(animation) }), 42); //With scroll
 #diamond { height: 290px; width: 351px; background: url('https://i.stack.imgur.com/HplbX.png') 0px 0px; background-size: 100%; overflow: hidden; }
 <div id="diamond"> </div>

De acuerdo con su ejemplo, aquí podría haber una solución para animar el diamante cuando se desplaza.

NOTA: Esta solución no es adecuada para la producción debido a la falla de los pasos de desplazamiento, pero puede usarla y modificarla para que se ajuste a sus necesidades.

 let bounding, height = 145, //Equal your diamond CSS height topPos = 0, scrollPos = 0, steps = 0, diamond = document.getElementById("diamond"); function scrollDiamond(o) { "down" === o && steps < 18 ? (act = `0px -${topPos+=height}px`, steps++) : "up" === o && steps > -1 && (act = `0px -${topPos-=height}px`, steps--) diamond.style.backgroundPosition = act; } window.addEventListener("scroll", (function() { bounding = document.body.getBoundingClientRect().top; bounding > scrollPos ? scrollDiamond("up") : scrollDiamond("down"), scrollPos = bounding }));
 body { height: 200vh; } #diamond { position: fixed; /* Your image heigh divided by 40 (or whatever you want) */ height: 145px; width: 175px; /* Your image width divided by 40 (or whatever you want)*/ background: url('https://i.stack.imgur.com/HplbX.png') 0px 0px/100%; }
 <div id="diamond"></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!