html - 如何使用 CSS 增加 unicode 图标相对于其容器的 Font Awesome 的大小

标签 html css unicode font-awesome

如何使用 CSS 增加 unicode 图标 awesome 字体相对于其容器的大小?

.iconTimes:before {
      display: block;
      font-family: FontAwesome;
      content: "\f00d"; 
 }

最佳答案

您可以使用 em 单位。假设您的 HTML 是

<div class="container">
  <i class="iconTimes"></i>
</div>

你的 CSS 可能是

.container { 
   font-size: 14px; //if this was not declared `.iconTimes` would have 2 x 16px = 32px
}

.iconTimes {
    font-size: 2em; //this will be 2 x 14px = 28px
}

.iconTimes:before {
    display: block;
    font-family: FontAwesome;
    content: "\f00d";
 }

Codepen here

If the font-size is not mentioned for any element it will be by default '16px', which means if you use '2em' and its parent's font-size is NOT declared then it will be 2x16px = 32px.

关于html - 如何使用 CSS 增加 unicode 图标相对于其容器的 Font Awesome 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40287509/

相关文章:

javascript - 元素切换类但不获取新类的样式

html - 如何让横尺不伸过来?

c++ - C++ 字符串的通用库

python - 在python中将字符串转换为unicode

html - 如何使具有可变高度内容的 3 "li"列具有相同的高度

javascript - 如何显示用户选择上传的图像

html - 固定位置 child 的 CSS clearfix 替代方案

unicode - 兼容范式中的字符串是否已经在相应的规范范式中?

html - VBA 从 Internet Explorer 的下拉列表中选择

c# - 2 "Dynamic"div 之间的 "Static"div [CSS][ASP.NET]