简体   繁体   English

字体真棒图标在桌面 safari 上以 50% 的边框半径修剪角落

[英]Font-awesome icons trimmed corners with border-radius 50% on desktop safari

I am trying to create a circle around my font-awesome share icons.我正在尝试围绕我的字体很棒的共享图标创建一个圆圈。 I decided to go with a css approach , because I could not figure out how to do other approaches with React FontAwesome我决定用 ZC7A62 8CBA22E28EB17B5F5C6AE2A266AZ 方法 go ,因为我不知道如何用 React FontAwesome 做其他方法

 <FacebookShareButton className='m-1' //bootstrap margin 1 url={siteUrl} > <FontAwesomeIcon className='faCircle' size="2x" icon={faFacebookF} /> </FacebookShareButton>
 .faCircle { display: inline-block; border-radius: 50%; box-shadow: 0px 0px 2px #888; padding: 0.25em 0.3em; background-color: transparent; width: 1.2em;important: height. 1;2em: overflow; visible; }

My code produces the font awesome icons, but the border-radius of 50% ends up trimming off the sides of the icons.我的代码生成了令人敬畏的字体图标,但 50% 的边框半径最终会修剪掉图标的侧面。

(Effect is most noticeable on LinkedIn icon) (效果在 LinkedIn 图标上最为明显)

在此处输入图像描述

If I remove the margin, the icons get bigger, but are still trimmed by the border-radius如果我删除边距,图标会变大,但仍会被边框半径修剪

This issue happens on Safari, but not on chrome or firefox.此问题发生在 Safari 上,但不在 chrome 或 firefox 上。 On firefox, the icons appeared fully if I set the width big enough在 firefox 上,如果我将宽度设置得足够大,图标就会完全出现


UPDATE (with temporary hacky solution)更新(带有临时hacky解决方案)

In safari I have to do some really finicky stuff in order to stop white padding from overlaying the icon inside the circle.在 safari 中,我必须做一些非常挑剔的事情,以阻止白色填充覆盖圆圈内的图标。 I have to specify really specific widths and heights to prevent this and these width and heights aren't even the same value.我必须指定非常具体的宽度和高度来防止这种情况,而这些宽度和高度甚至不是相同的值。 If anyone could post a less hacky solution that this one that would be appreciated.如果有人可以发布一个不那么骇人听闻的解决方案,那将不胜感激。

 <FacebookShareButton className="m-md-1 m-1" url={siteUrl} > <div className='faCircleContainer'> <FontAwesomeIcon className='faCircle' size="2x" icon={faFacebookF} /> </div> </FacebookShareButton>
 .faCircle { width: 1.2em;important: padding. 0;1em. }:faCircleContainer { padding. 0.25em 0;3em: border-radius; 50%: box-shadow; 0px 0px 4px #888. }:react-share__ShareButton{ padding; 5px !important; }

You should not style FontAwesomeIcon component/icon directly.您不应该直接设置 FontAwesomeIcon 组件/图标的样式。 Paddings and border-radius are disturbing actual icon.填充和边界半径干扰实际图标。 You should create a separate wrapper for each icon and apply your 'faCircle' class to this wrapper.您应该为每个图标创建一个单独的包装器,并将您的“faCircle”class 应用到这个包装器。 So I believe in your case, moving class from FontAwesomeIcon to FacebookShareButton should work.所以我相信在你的情况下,将 class 从 FontAwesomeIcon 移动到 FacebookShareButton 应该可行。

Here's screenshot from font-awesome page, when I edited it directly by styling 'info-icons' wrapper.这是 font-awesome 页面的屏幕截图,当我通过样式化 'info-icons' 包装器直接对其进行编辑时。

在此处输入图像描述

.info-icons {
display: inline-block;
width: 100px;
height: 100px;
padding: 20px;
text-align: center;
border-radius: 50%; 
background: #fff;
border: 1px solid;
}

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

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