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

300
Vistas
change color of text, image and background on hover

I want to change color of the image too on hover by applying a filter: brightness(10) but it's whiting all the button, so I don't know how to change the icon color.

button hover

for example you can use

<div class="hello"><img src="https://i.ibb.co/HBbfCGF/play.png">bouton</div>

<style>
.hello {background-color: #eeeeee;color: #4171af;font-size: 20px}
.hello:hover{background-color: #4171af; color: white;}

</style>

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

0

Add a filter to the image only:

.hello {
  background-color: #eeeeee;
  color: #4171af;
  font-size: 20px
}

.hello:hover {
  background-color: #4171af;
  color: white;
}

.hello:hover img {
  filter: brightness(150%);
}
<div class="hello"><img src="https://i.ibb.co/HBbfCGF/play.png">bouton</div>

about 4 years ago · Juan Pablo Isaza Denunciar

0

I recommand you to create a second image file and on hover change the image src attribute using JavaScript to the brighter file. It also allows you to be more creative than just increasing the brightness value.

It's a simple task, but I'll rather explain it detail. It seems, that you have dealt with the basic CSS hover effects with no problem, so I'll just show you the JavaScript.

Your HTML looks probably like this (i added a class to the img and linked the JavaScript):

<div class="hello">
    <img class="play" src="https://i.ibb.co/HBbfCGF/play.png">
    <span>Button</span>
</div>
<script src="script.js"></script>

Now, you want to change the attribute src="" of the <img> tag, when hovering over the whole <div>. And when the mouse is no longer hovering over the <div>, you want to set it to the default.

You'll need to use the addEventListener() and setAttribute() functions.

let hello = document.querySelector('.hello');
hello.addEventListener('mouseover', function(){
   let img = document.querySelector('.play');
   img.setAttribute('img', 'path/to/the/second/file.png');
});
hello.addEventListener('mouseout', function(){
   let img = document.querySelector('.play');
   img.setAttribute('img', 'https://i.ibb.co/HBbfCGF/play.png');
});
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