简体   繁体   English

如何在悬停时更改fontawesome图标背景? jsfiddle

[英]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>

http://jsfiddle.net/5hzv3/27/ http://jsfiddle.net/5hzv3/27/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在悬停时更改带有文本的FontAwesome图标 - Change FontAwesome icon with text on hover 在 hover 上将 FontAwesome 图标更改为文本 - Change FontAwesome icon to text on hover 如何使用 onclick 功能更改 FontAwesome 的悬停颜色? - How to change the hover color for the FontAwesome with onclick function? 如何在悬停时更改图标(fontawesome图标) - How to change icons (fontawesome icons) on hover 如何更改div内fontawesome图标的属性? - How to change the properties of a fontawesome icon inside a div? 将鼠标悬停在li上并改变背景? - Hover over li and the backgrounds change? 如何更改悬停CSS上的图标 - how to change icon on hover css 如何更改 hover 上的图标颜色? - How to change icon color on hover? 用整个字体制作 fontawesome 图标 hover<div id="text_translate"><p> 请帮助我如何使用&lt;导航菜单上的链接制作字体真棒图标 hover</p><p> 我试过了:</p><p> li a.sc-ico:hover, .fa-windows:hover:before {color:blue;important;}</p><p> 它有效,但 hover 效果仅适用于 fontawesome 图标,当我在整个 &lt;a 链接上使用 hover 时,我需要 fontawesome hover。</p><p> 任何帮助表示赞赏</p></div> - Make fontawesome icon hover with entire <a on navigation menu 是否可以在悬停时在两个 fontawesome 图标之间切换? - Is it possible to change between two fontawesome icons on hover?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM