【问题标题】:Is it possible to make Font Awesome icons larger than 'fa-5x'?是否可以使 Font Awesome 图标大于“fa-5x”?
【发布时间】:2014-11-01 09:08:55
【问题描述】:

我正在使用这个 HTML 代码:

<div class="col-lg-4">
  <div class="panel">
    <div class="panel-heading">
      <div class="row">
        <div class="col-xs-3">
          <i class="fa fa-cogs fa-5x"></i>
        </div>
        <div class="col-xs-9 text-right">
          <div class="huge">
            <?=db_query("SELECT COUNT(*) FROM orders WHERE customer = '" . $_SESSION['customer'] . "' AND EntryDate BETWEEN '" . date('d-M-y', strtotime('Monday this week')) . "' AND '" . date('d-M-y', strtotime('Friday this week')) . "'");?>
          </div>
            <div>orders this week</div>
        </div>
      </div>
    </div>
    <a href="view/orders">
      <div class="panel-footer">
        <span class="pull-left">View Details</span>
          <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
            <div class="clearfix"></div>
      </div>
    </a>
  </div>
</div>

创建:

是否可以让图标大于fa-5x?它下面有很多空白空间,我希望它占据。

【问题讨论】:

    标签: html css twitter-bootstrap font-awesome


    【解决方案1】:

    Font awesome 只是一种字体,因此您可以使用 CSS 中的字体大小属性来更改图标的大小。

    所以你可以像这样向图标添加一个类:

    .big-icon {
        font-size: 32px;
    }
    

    【讨论】:

      【解决方案2】:

      您也可以编辑源代码并创建自己的增量

      FontAwesome 5

      https://github.com/FortAwesome/Font-Awesome/blob/5.15.4/less/_larger.less

      // Icon Sizes
      // -------------------------
      
      .larger(@factor) when (@factor > 0) {
        .larger((@factor - 1));
      
        .@{fa-css-prefix}-@{factor}x {
          font-size: (@factor * 1em);
        }
      }
      
      /* makes the font 33% larger relative to the icon container */
      .@{fa-css-prefix}-lg {
        font-size: (4em / 3);
        line-height: (3em / 4);
        vertical-align: -.0667em;
      }
      
      .@{fa-css-prefix}-xs {
        font-size: .75em;
      }
      
      .@{fa-css-prefix}-sm {
        font-size: .875em;
      }
      
      // Change the number below to create your own incrementations
      // This currently creates classes .fa-1x - .fa-10x
      .larger(10);
      

      FontAwesome 4

      https://github.com/FortAwesome/Font-Awesome/blob/v4.7.0/less/larger.less

      // Icon Sizes
      // -------------------------
      
      /* makes the font 33% larger relative to the icon container */
      .@{fa-css-prefix}-lg {
          font-size: (4em / 3);
          line-height: (3em / 4);
          vertical-align: -15%;
      }
      
      .@{fa-css-prefix}-2x { font-size: 2em; }
      .@{fa-css-prefix}-3x { font-size: 3em; }
      .@{fa-css-prefix}-4x { font-size: 4em; }
      .@{fa-css-prefix}-5x { font-size: 5em; }
      
      // Your custom sizes
      .@{fa-css-prefix}-6x { font-size: 6em; }
      .@{fa-css-prefix}-7x { font-size: 7em; }
      .@{fa-css-prefix}-8x { font-size: 8em; }
      

      【讨论】:

        【解决方案3】:

        您可以重新定义/覆盖默认的 font-awesome 尺寸,也可以添加您自己的尺寸

        .fa-1x{
            font-size:0.8em;
        }
        .fa-2x{
            font-size:1em;
        }
        .fa-3x{
            font-size:1.2em;
        }
        .fa-4x{
            font-size:1.4em;
        }
        .fa-5x{
            font-size:1.6em;
        }
        .fa-mycustomx{
            font-size:3.2em;
        }
        

        【讨论】:

          【解决方案4】:
          1. 只需像这样添加字体真棒类:

            class="fa fa-plus-circle fa-3x"
            

            (您可以按 5x、7x、9x.. 增加尺寸)

          2. 您还可以添加自定义 CSS。

          【讨论】:

            【解决方案5】:

            简单——只需使用 Font Awesome 5 的默认 fa-[size]x 类。您可以将图标缩放到父元素的 font-size Read the docs about icon sizing. 的 10 倍

            示例:

            <span class="fas fa-info-circle fa-6x"></span>
            <span class="fas fa-info-circle fa-7x"></span>
            <span class="fas fa-info-circle fa-8x"></span>
            <span class="fas fa-info-circle fa-9x"></span>
            <span class="fas fa-info-circle fa-10x"></span>
            

            【讨论】:

              【解决方案6】:

              字体真棒使用 SVG 图标。因此,您可以根据需要调整其大小。

              只需使用 CSS 类,

                  .large-icon{
                     font-size:10em;
                     //or
                    font-size:200%;
                    //or
                    font-size:50px;
                  }
              

              【讨论】:

                【解决方案7】:

                您还可以使用 CSS 定义缩放转换,如下所示:

                .larger-icon {
                 transform:scale(2);
                }
                

                【讨论】:

                  猜你喜欢
                  • 2014-09-13
                  • 1970-01-01
                  • 1970-01-01
                  • 2015-08-29
                  • 1970-01-01
                  • 2014-10-01
                  • 1970-01-01
                  • 1970-01-01
                  • 2014-07-13
                  相关资源
                  最近更新 更多