简体   繁体   English

字体真棒叠加图标悬停大纲问题

[英]Font Awesome stacked icon hover outline issue

I am using font awesome stacked icon.My code is: 我正在使用字体很棒的堆叠图标。我的代码是:

<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 code to change color when mouse hover is: 鼠标悬停时更改颜色的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");
});

it's all working but when i mouse hover the icons many time icon right side small line visible.how to fix it.This problem only on chrome browser. 这一切都工作,但当我鼠标悬停图标许多时间图标右侧小线visible.how来修复它。这个问题只在Chrome浏览器上。

This my image: 这是我的形象: 在此输入图像描述

my css code: 我的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;
                   }

Here's a CSS-only solution: http://jsfiddle.net/h66t0sde/1/ 这是一个仅限CSS的解决方案: http//jsfiddle.net/h66t0sde/1/

CSS: 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: 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>

As a side note, you should avoid classes that include color names, since that locks you into either having confusing names later (if the colors change) or having to track down everywhere you've used it (if you change the name to match the new color). 作为旁注,您应该避免使用包含颜色名称的类,因为这会阻止您在以后使用令人困惑的名称(如果颜色发生变化)或者必须在您使用它的任何地方追踪(如果您更改名称以匹配新的颜色)。

I also didn't want to rely on the FontAwesome classes for the effect, since those have already changed once. 我也不想依赖FontAwesome类来获得效果,因为那些已经改变了一次。 To that end, I came up with some names for the relevant bits that seemed appropriate. 为此,我想出了一些似乎合适的相关位的名称。

As for the line you're seeing: no idea. 至于你所看到的那条线: 不知道。 I don't see that in this jsFiddle when viewing it in Chrome or Firefox, so if you're still seeing it, something in the rest of your CSS is causing that. 我在Chrome或Firefox中查看时没有看到这个jsFiddle,所以如果你仍然看到它,那么CSS的其他内容就会导致这种情况发生。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM