【问题标题】:Remove white border around font awesome icon删除字体真棒图标周围的白色边框
【发布时间】:2023-04-05 16:23:01
【问题描述】:

我一直在尝试将字体真棒图标破解为全蓝色,图标为白色,但这是我最接近的。知道我需要添加/删除什么吗?尝试了透明边框,删除填充/边距,定位在一个跨度后面,但没有运气。

 

   .b-social-media-shares__a {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        text-align: center;
        margin: 0 6px;

        &:hover {
            box-shadow: 1px 3px 5px grey;
        }

        i {
            color: white;
            line-height: 48px;
            font-size: 25px;
        }


    }
    .b-social-media-shares--facebook {
      background-color: #4267B2;
    }

    .b-social-media-shares--facebook .fa-facebook-f {
      color: #4267B2;
      line-height: 48px;
      font-size: 28px;
    }

    .b-social-media-shares--facebook .fa-facebook-f:before {
      content: "\f09a";
      background-color: white;
      border-radius: 50%;
    }

    .b-social-media-shares--facebook:hover {
      background-color: white;
    }

    .b-social-media-shares--facebook:hover i {
      color: #4267B2;
    }
<a id="facebook" href="" class="b-social-media-shares__a b-social-media-shares--facebook dnt" target="_blank">
  <i class="fab fa-facebook-f"></i>
</a>

【问题讨论】:

    标签: html css sass font-awesome


    【解决方案1】:

    一些不必要的和一些冲突的风格。见代码中的cmets:

    .b-social-media-shares__a {
      display: inline-flex; // added
      align-items: center; // added
      justify-content: center; // added
      text-decoration: none; // added, but not required (removes the underline)
    
      width: 48px;
      height: 48px;
      border-radius: 50%;
      // text-align: center; // not required because of `justify-content`
      margin: 0 6px;
    
      &:hover {
        box-shadow: 1px 3px 5px grey;
      }
    
      i {
        color: white;
        // line-height: 48px; // not really required
        font-size: 25px;
      }
    }
    .b-social-media-shares--facebook {
      background-color: #4267b2;
    }
    
    .b-social-media-shares--facebook .fa-facebook-f {
      // color: #4267b2; // not required (it should be white)
      // line-height: 48px; // not really required
      font-size: 28px;
    }
    
    // This whole ruleset is not required
    // .b-social-media-shares--facebook .fa-facebook-f:before {
    //   content: "\f09a";
    //   background-color: white;
    //   border-radius: 50%;
    // }
    
    .b-social-media-shares--facebook:hover {
      background-color: white;
    }
    
    .b-social-media-shares--facebook:hover i {
      color: #4267b2;
    }
    
    

    【讨论】:

    • 做到了。我试图破解一些没有良好基础的东西。谢谢查尔斯
    【解决方案2】:

    也许作为替代解决方案,您可以只将“f”放在蓝色圆圈中

    我做了这个sn-p,希望对你有帮助:

    https://codesandbox.io/s/icy-dust-2vfvi?file=/src/index.js:69-132

    【讨论】:

    • 在测试中看起来不错,但是 .fa-facebook-f { color: white; } 我的整个圆圈都变成白色了
    • @MPortman 您是否将图标从“fab fa-facebook”更改为“fab fa-facebook-f”?请记住,您使用的是带有 f 的整个圆圈,您只需要使用“f”图标:fontawesome.com/icons/facebook-f?style=brands
    【解决方案3】:

    没有边框...您将一个圆形图标放在比图标大的圆形元素内。包装元素具有白色背景和蓝色边框。此背景显示在您的图标后面。

    改变

    .b-social-media-shares--facebook .fa-facebook-f:before {
          background-color: white;
        }
    

    要有蓝色背景...

    【讨论】:

    • 那么整个圆圈和图标都是蓝色的。我们的想法是让“f”为白色,这是背景颜色出现的地方,但它会溢出图标。
    • 那就用不带圆圈的版本...fontawesome.com/v4.7.0/icon/facebook自己做背景
    猜你喜欢
    • 1970-01-01
    • 2017-10-28
    • 1970-01-01
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 2016-02-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多