[英]Font Awesome stacked icon hover outline issue
我正在使用字体很棒的堆叠图标。我的代码是:
<span id="twitterBox" class="fa-stack"><i id="faTwittertSquare" class="fa fa-square fa- stack-2x colorOrange"></i><i id="fatwitter" class="fa fa-twitter fa-stack-1x colorWhite" title="twitter"></i></span>
<span id="facebookBox" class="fa-stack"><i id="faFacebookSquare" class="fa fa-square fa-stack-2x colorOrange"></i><i id="faFacebook" class="fa fa-facebook fa-stack-1x colorWhite" title="facebook"></i></span>
鼠标悬停时更改颜色的jquery代码:
$("#twitterBox").hover(function(){
$("#faTwittertSquare").removeClass("colorOrange");
$("#faTwittertSquare").addClass("colorWhite");
$("#fatwitter").removeClass("colorWhite");
$("#fatwitter").addClass("colorOrange");
},function(){
$("#faTwittertSquare").removeClass("colorWhite");
$("#faTwittertSquare").addClass("colorOrange");
$("#fatwitter").removeClass("colorOrange");
$("#fatwitter").addClass("colorWhite");
});
$("#facebookBox").hover(function(){
$("#faFacebookSquare").removeClass("colorOrange");
$("#faFacebookSquare").addClass("colorWhite");
$("#faFacebook").removeClass("colorWhite");
$("#faFacebook").addClass("colorOrange");
},function(){
$("#faFacebookSquare").removeClass("colorWhite");
$("#faFacebookSquare").addClass("colorOrange");
$("#faFacebook").removeClass("colorOrange");
$("#faFacebook").addClass("colorWhite");
});
这一切都工作,但当我鼠标悬停图标许多时间图标右侧小线visible.how来修复它。这个问题只在Chrome浏览器上。
这是我的形象:
我的css代码:
.fa-stack {
position: relative;
display: inline-block;
width: 2em;
height: 2em;
line-height: 2em;
vertical-align: middle;
}
.fa {
display: inline-block;
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.fa-square-o:before {
content: "\f096";
}
.fa-square:before {
content: "\f0c8";
}
.fa-stack-2x {
font-size: 2em;
}
.fa-stack-2x {
position: absolute;
left: 0;
width: 100%;
text-align: center;
}
.fa-twitter:before {
content: "\f099";
}
.fa-facebook:before {
content: "\f09a";
}
.colorWhit{
color:#FFFFFF;
}
.colorOrange{
color:#FFA500;
}
这是一个仅限CSS的解决方案: http : //jsfiddle.net/h66t0sde/1/
CSS:
span.social-box i.social-inner{
color:#FFA500;
}
span.social-box i.social-outer{
color:#fff;
}
/* Swap colors on hover */
span.social-box:hover i.social-inner{
color:#fff;
}
span.social-box:hover i.social-outer{
color:#FFA500;
}
HTML:
<span id="twitterBox" class="fa-stack social-box">
<i id="faTwittertSquare" class="fa fa-square fa-stack-2x social-outer"></i>
<i id="fatwitter" class="fa fa-twitter fa-stack-1x social-inner" title="twitter"></i>
</span>
<span id="facebookBox" class="fa-stack social-box">
<i id="faFacebookSquare" class="fa fa-square fa-stack-2x social-outer"></i>
<i id="faFacebook" class="fa fa-facebook fa-stack-1x social-inner" title="facebook"></i>
</span>
作为旁注,您应该避免使用包含颜色名称的类,因为这会阻止您在以后使用令人困惑的名称(如果颜色发生变化)或者必须在您使用它的任何地方追踪(如果您更改名称以匹配新的颜色)。
我也不想依赖FontAwesome类来获得效果,因为那些已经改变了一次。 为此,我想出了一些似乎合适的相关位的名称。
至于你所看到的那条线: 不知道。 我在Chrome或Firefox中查看时没有看到这个jsFiddle,所以如果你仍然看到它,那么CSS的其他内容就会导致这种情况发生。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.