代码之家  ›  专栏  ›  技术社区  ›  David

FontAwesome图标在Safari中比Chrome更高

  •  3
  • David  · 技术社区  · 9 年前

    我不知道为什么会发生这种情况,但我的FontAwesome图标在Safari中出现了偏移。

    在Chrome中,它们看起来是这样的:

    enter image description here

    在Safari中,像这样:

    enter image description here

    现在,我正在使用基金会,React。js和FontAwesome,因此通过JSFiddle提供CSS非常麻烦。我试着尽我所能地剥皮,让它变得光秃秃的,我相信你仍然可以看到它发生在 this JSFiddle 。只需在Safari中查看,然后在Chrome中查看,就会发现偏移。

    以下是JSFiddle的布局:

    HTML:

    <div class="line">
      <i class="fa fa-cog"></i>
      <span class="name" >cfb</span>
    </div>
    

    CSS:

    .line {
        color: #60b0c6;
        text-transform: capitalize; 
    }
    
    .name {
        font-size: 13px;
        cursor: pointer;
        width: 93%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: inline-block;
        position: relative;
        top: 6px;
        left: 2px; 
    }
    
    .fa-cog {
        font-size: 12px;
        margin-right: 4px;
        opacity: 1;
        cursor: pointer;
        color: #333; 
    }
    
    .fa {
        position: relative;
        display: inline-block;
        font: normal normal normal 14px/1 FontAwesome;
        font-size: inherit;
        text-rendering: auto;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale; 
    }
    

    我不知道如何解决这个问题,我很困惑。

    编辑:垂直对齐在我这边不起作用。

    3 回复  |  直到 9 年前
        1
  •  2
  •   Praveen Kumar Purushothaman    9 年前

    正在添加 vertical-align 修复它:

    .fa {
        position: relative;
        display: inline-block;
        font: normal normal normal 14px/1 FontAwesome;
        font-size: inherit;
        text-rendering: auto;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        vertical-align: middle; /* Or try bottom or baseline */
    }
    
        2
  •  -1
  •   ketan    9 年前

    去除 top left 从…起 .name 分类并给出 vertical-align 会成功的。

    这里我用 vertical-align:top;

    .name {
        font-size: 13px;
        cursor: pointer;
        width: 93%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: inline-block;
        position: relative;
        vertical-align:top; //Here.
    }
    
    .fa {
        position: relative;
        display: inline-block;
        vertical-align:top; // Here
        font: normal normal normal 14px/1 FontAwesome;
        font-size: inherit;
        text-rendering: auto;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    

    Working Fiddle 已登录Firefox、Chrome、Safari。

        3
  •  -1
  •   Peyman Mohamadpour    9 年前

    我认为你可以通过定义 vertical-align: middle .