html - Font Awesome 边框

标签 html css font-awesome

我正在尝试为我的超赞字体图标添加边框,如下图所示: enter image description here

是的,我设法做到了,但这不是正确的方法,我会在您看到我的代码后向您解释原因:

HTML:

        <div id= "contact">


        <i class="fa fa-envelope-o fa-2x"></i>
        <i class="fa fa-phone fa-2x"></i>

       </div>

还有 CSS:

/*font awesome*/

i.fa-envelope-o {
  width:50px;
  height:50px;
   display: inline-block;
   border:2px solid white;
  border-radius: 60px;

}
.fa-envelope-o {

  padding-top: 5px;
}

i.fa-phone {
  width:50px;
  height:50px;
   display: inline-block;
   border:2px solid white;
  border-radius: 60px;

}

.fa-phone {

  padding-top: 5px;
}

如您所见,这不是正确的方法,如果我必须再次使用信封图标但没有边框怎么办?为了使它居中,我不得不使用 padding top。有没有更清洁的方法来做到这一点?我不想单独使用 i 标签,因为上面的文本同时使用了它,例如:

<p><i>hello</i></p>

提前致谢, 凯文

最佳答案

试试这个:

div#contact {
  background-color: black;
}
#contact i.fa {
  border: 2px solid #fff;
  border-radius: 60px;
  color: #fff;
  display: inline-block;
  height: 30px;
  margin: 5px;
  padding: 15px;
  width: 30px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css">
<div id= "contact">


        <i class="fa fa-envelope-o fa-2x"></i>
        <i class="fa fa-phone fa-2x"></i>

       </div>

关于html - Font Awesome 边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37203547/

相关文章:

javascript/jquery : on click copy relevant array items to new array

HTML 页面无法加载 CSS 文件,找不到资源错误

javascript - 改进 JavaScript - 用于事件菜单和显示/隐藏 div 的 jQuery 代码

android - CSS 显示 : none not working on Samsung S5 mini

html - 我的媒体查询适用于我的 iphone 但不适用于浏览器调整大小

html - Font Awesome 未显示在我的本地主机上

HTML 标签文本内容替换为图标

css - Font Awesome 5,为什么不显示 CSS 内容?

html - MooTools - 如何使用 getSelected()

javascript - 直接链接到此网页