Changing background on hover.

I would like to make the background lighter on hover.  What I have is not working. Its on the streaming services.  Amazon, etc.
http://mediascrubber.com/index.html

<div>
  	<a href="">
    <img src ="socials\music-service_amazon.svg" class="service">
    </a>
</div>

Open in new window


.service a:hover {
	transition: background-color .3s ease;
    background-color: #9f9145;
	}

Open in new window

David SchureAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Zakaria AcharkiAnalyst DeveloperCommented:
Your rule trys to traget the anchor inside element with .service class what is the img when there's no anchor inside it, it must be :

#hap-wrapper a:hover {
   transition: background-color .3s ease;
    background-color: #9f9145;
}

Open in new window


Or you could attach the rules directly to the image like :

.service:hover{
    filter: brightness(110%); 
}

Open in new window

David SchureAuthor Commented:
I tried both and neither worked.
Julian HansenCommented:
Try this

.service:hover {
	opacity: 0.5;
}

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Zakaria AcharkiAnalyst DeveloperCommented:
I have already tested on your website the following rule and it works just fine:

.service:hover{
    filter: brightness(110%); 
}

Open in new window


I suggest also to give the items with class service a low opacity as 0.5 for example then toggle it to 1 on hover, something like :

.service {
    display: block;
    padding-bottom: 10px;
    margin-right: auto;
    margin-left: auto;
    max-width: 180px;
    opacity: 0.5;
}

Open in new window


Then on hover :

.service:hover{
    opacity: 1; 
}

Open in new window


LIVE EXAMPLE
fxPTaH3vwz.gif
David SchureAuthor Commented:
Okay these work.  However I was aiming for something like this..... where the entire background becomes lighter.

https://islandrecs.lnk.to/Sober
Zakaria AcharkiAnalyst DeveloperCommented:
Then the selector you're looking for is #hap-wrapper div, example:

#hap-wrapper div:hover {
    transition: background-color .3s ease;
    background-color: #9f9145;
}

Open in new window


You could use the previous selector with the other one using opacity to toggle the opacity and background color on hover.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
Alternatively
#hap-wrapper > div:hover {
	background: rgba(255,255,255,.05);
}

Open in new window

Zakaria AcharkiAnalyst DeveloperCommented:
You could also use the :not(:first-child) selector to exclude the first div from the rules and prevent toggle effect for the cover image and the text just before the list of music services:

#hap-wrapper>div:not(:first-child){
    /* Your attributes here */
}

Open in new window

David SchureAuthor Commented:
Yes these work.  Is there a way to exclude the picture and the song info from the mix?

<div id="highlight">
  	<a href="">
    <img src ="socials\music-service_amazon.svg" class="service">
    </a>
    <!--div class="play">Download</div-->
</div>

Open in new window


#highlight div:hover {
    transition: background-color .3s ease;
    background-color: #9f9145;
}

Open in new window


I tried naming the div's containing the music services and adding the code to it but it did nothing.
Zakaria AcharkiAnalyst DeveloperCommented:
Check my the previous comment covering that using :not(:first-child) selector.
David SchureAuthor Commented:
That turned out weird....it selected almost everything.....

#hap-wrapper>div:not(:first-child){
    transition: background-color .3s ease;
    background-color: #9f9145;
}

Open in new window

David SchureAuthor Commented:
This worked.
#hap-wrapper>div:not(:first-child):hover{
    transition: background-color .3s ease;
    background-color: #9f9145;
}

Open in new window

Zakaria AcharkiAnalyst DeveloperCommented:
Yes my bad sorry, I have just missed the :hover
David SchureAuthor Commented:
Thanks to the both of you.  This really helped me and I learned a lot!
Zakaria AcharkiAnalyst DeveloperCommented:
You're welcome anytime.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.