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

166
Views
CSS rotar transformar desordena el desplazamiento sobre el elemento hermano

Estoy tratando de implementar una superposición en un elemento de imagen, con un botón dentro que te permite rotar la imagen 180 grados. Esto funciona bien hasta que rotas la imagen por primera vez, luego la superposición no volverá a aparecer o por alguna razón está detrás de la etiqueta de la imagen. Intenté configurar el índice z de la imagen en -999 pero eso no hizo nada. . Necesito la solución para trabajar en dispositivos móviles, por lo que trabajar con detectores de eventos onmouseover no era una opción para mí.

Código Sandbox aquí

Código:

 <div class="relative"> <div class="absolute overlay"> <button id="rotate">Click to Rotate this Image 180 Degrees</button> </div> <div> <img id="image-to-rotate" src="https://picsum.photos/200/300" /> </div> </div>
 import "./styles.css"; document.getElementById("rotate").addEventListener("click", () => { document.getElementById("image-to-rotate").classList.toggle("rotate"); });
 .relative { position: relative; height: 300px; width: 200px; } .absolute { color: white; position: absolute; background-color: rgba(0, 0, 0, 0.6); height: 100%; width: 100%; /*invisible by default*/ opacity: 0; } .absolute:hover, .absolute:active { /*show on hover, also on activate to work on mobile*/ opacity: 1; } .rotate { transform: rotate(180deg); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

 .absolute:hover, .absolute:active, .absolute:visited { /*show on hover*/ opacity: 1; z-index: 999; }

Agregué el visitado a su css y el índice z y permanece después de hacer clic.

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!