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

190
Vistas
Button Keeps :hover effect after being clicked on Mobile Screens

I have this scroll to top button that when it gets clicked on mobile screens, it keeps the color I've set for its hover effect and doesn't go back to the original one.

#back-to-top {
  background: none;
  background-repeat: no-repeat;
  border: none;
  cursor: pointer;
  overflow: hidden;
  outline: none;
  position: fixed;
  bottom: 30px;
  right: 20px;
  color: rgb(255, 51, 0);
  z-index: 99;
  font-size: 2.5rem;
}

#back-to-top:hover {
  color: rgb(255, 0, 140);
}

This is the initial color of the button:

enter image description here

And after it's clicked on Mobile Screens, it keeps its new color until I click somewhere on the screen:

enter image description here

This only happens on Touch Screens and not in Desktop since the hover effect is somehow taken as a focus on Touch Screens.

How can I avoid this and keep the original color after it's clicked?

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

0

Try changing the color on hover only if the device has true hover functionality:

#back-to-top {
  background: none;
  background-repeat: no-repeat;
  border: none;
  cursor: pointer;
  overflow: hidden;
  outline: none;
  position: fixed;
  bottom: 30px;
  right: 20px;
  color: rgb(255, 51, 0);
  z-index: 99;
  font-size: 2.5rem;
}

@media (hover: hover) {
  #back-to-top:hover {
    color: rgb(255, 0, 140);
  }
}
<button id="back-to-top">Top</button>

about 4 years ago · Juan Pablo Isaza Denunciar

0

Since this part of CSS Media Queries Level 4 has now been widely implemented since 2018, you can use this

@media (hover: hover) {
button:hover {
    background-color: blue;
   } }
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