Reputation: 10649
I am trying to create icons using fontawesome by inserting an icon inside an open square. On hover, I would like to change the color of the background inside the square, as well as the actual color of the square and the icon color.
I have put an example here: http://jsfiddle.net/5hzv3/2/
.social-icons .fa-square-o:hover {
background-color: #3b5998; /* This overflows outside the square */
color: #fff
}
The problem is that you're actually hovering over the square's child element, so I'm trying to get this to work.
Upvotes: 1
Views: 9461
Reputation: 31
Building off Felipe Miosso's example, I figured out how to do this minimally and still use the official icons:
<style>
.fa-stack .fa { color: #000000; }
.fa-stack .fa.fa-square { color: #FFFFFF; }
.fa-stack:hover .fa.fa-facebook-square { color: #3B5998; }
</style>
<span class="fa-stack">
<i class="fa fa-square fa-stack-1x"></i>
<i class="fa fa-facebook-square fa-stack-1x"></i>
</span>
Upvotes: 3
Reputation: 7339
That's what you need?
fiddle: http://jsfiddle.net/5hzv3/6/
Just changed your css to this:
.fa-lg:hover { color: #fff }
.fa-lg:hover > i { color: #3b5998; }
If only the square must change. This is the code:
.fa-lg:hover { color: #fff }
.fa-lg:hover > .fa-square-o { color: #3b5998; }
Edited I created an example that might help you. It's NOT a generic css that fits in every case, buuut, might give you ideas.
Hope it helps ... http://jsfiddle.net/5hzv3/15/
Upvotes: 4