在圆形边框中以正确的1:1比例制作Font Awesome图标 [英] Make Font Awesome icons in a circle border with right 1:1 ratio

查看:50
本文介绍了在圆形边框中以正确的1:1比例制作Font Awesome图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些情况下,如果图标的比例不为1:1,则边框不再是圆形.

In some case, if the ratio of the icon is not 1:1, the border is not a circle anymore.

这是一个例子:

我当前正在使用:

HTML:

.socials
      a(href='#') <i class="fa fa-facebook"></i>
      a(href='#') <i class="fa fa-twitter"></i>
      a(href='#') <i class="fa fa-google"></i>

SASS:

      border-radius: 50%
      border: solid white
      padding: 10px

无论如何,我可以使用CSS来解决问题吗?

Is there anyway that I can use CSS to fix the problem?

推荐答案

您需要设置宽度,高度,行高和&文本对齐以使图标居中.图标,还需要将垂直对齐"重置为中间位置.

You need to set width, height, line height, & text-align to center the icon. icon will need also vertical-align reset to middle.

避免以像素为单位的填充,但在em或rem中使用width/height/line-height.然后,您可以更改字体大小并保持比例,而无需更新其他值.

Avoid padding in pixels, but use width/height/line-height in em or rem. You can then change font-size and keep the ratio without updating other values.

a /* or selector a .fa */
  {  
  font-size:3em;
  border-radius: 50%;
  border: solid white;
  color: white;
  line-height: 2em;
  width: 2em;
  height: 2em;
  text-align: center;
  display: inline-block;
    transition:0.5s;
}
/* demo purpose */
a:hover {font-size:2em}
.fa {
/* optionnal vertical-align: middle;*/
}
body {
  background: #333
}

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<a href="#"><i class="fa fa-facebook"></i></a>
<a href="#"><i class="fa fa-twitter"></i></a>
<a href="#"> <i class="fa fa-google"></i>
</a>

这篇关于在圆形边框中以正确的1:1比例制作Font Awesome图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆