Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Social media icon swapping

Okay I have two images for a facebook icon. One image is a dark color for the normal state and the other is a blue color for when you hover over it. How do I code it so when I hover over the image it switches from the dark to the blue color?

This is what I have so far but all it does is turn the opacity down for the dark image and you don't see the blue image.

Html:

<div id="facebook_swap">                              
                    <img src="img/facebook_dark.png" alt="facebook">
</div>

css:

    #facebook_swap{
width:32px;
height:32px;
background-image:url("img/facebook_active.png");    

}

    #facebook_swap img:hover{ 
opacity:0; 

}

4 Answers

Kevin Korte
Kevin Korte
28,148 Points

ohh, mmmm. And I assume you've triple checked the image name.

Check out this codepen I did using your code as a base, and see if you don't see a difference. I can't figure it out yet. So it must be something small that is causing it to not work.

http://codepen.io/anon/pen/rhbLF

Kevin Korte
Kevin Korte
28,148 Points

Try removing the space between the url and the parenthesis in the CSS.

Their actually isn't one. It just looks like that in here.

You were right. I must have spelled the file wrong. hahaha Thanks.

Kevin Korte
Kevin Korte
28,148 Points

Been there, got that t-shirt :) Glad to hear it.