[英]How to change fontawesome icon backgrounds on hover? jsfiddle
I am trying to create icons using fontawesome by inserting an icon inside an open square. 我试图通过在空心方形内插入图标来使用fontawesome创建图标。 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/ 我在这里举了一个例子: 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. 问题是您实际上将鼠标悬停在正方形的子元素上,因此我正在尝试使其工作。
That's what you need? 那就是你所需要的?
fiddle: http://jsfiddle.net/5hzv3/6/
小提琴: http
: //jsfiddle.net/5hzv3/6/
Just changed your css to this: 刚刚将您的CSS更改为:
.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.
它不是适用于所有情况的通用CSS,buuut可能会给您一些想法。
Hope it helps ... http://jsfiddle.net/5hzv3/15/ 希望对您有所帮助... http://jsfiddle.net/5hzv3/15/
Building off Felipe Miosso's example, I figured out how to do this minimally and still use the official icons: 在Felipe Miosso的示例的基础上,我想出了如何做到这一点的方法,并且仍然使用官方图标:
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.