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

298
Views
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 answers
Answer question

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 Report

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 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!