【问题标题】:CSS - Chrome/Safari same font-weight not applying when uploading to WordpressCSS - 上传到 Wordpress 时,Chrome/Safari 相同的字体粗细不适用
【发布时间】:2018-04-11 06:28:06
【问题描述】:

我有一个使用 HTML5 Blank 子主题上传到 Wordpress 的前端网站。一些悬停文本的字体粗细存在非常明显的差异 - 以及页脚 - 我在独立的前端版本中没有看到。

示例 - 页脚

示例 - 悬停文本

这就是我的风格 -

style.css

@font-face {
    font-family: 'GothamLight';
    src: url('fonts/GothamLight.eot');
    src: url('fonts/GothamLight.eot') format('embedded-opentype'),
         url('fonts/GothamLight.woff2') format('woff2'),
         url('fonts/GothamLight.woff') format('woff'),
         url('fonts/GothamLight.ttf') format('truetype'),
         url('fonts/GothamLight.otf') format('opentype'),
         url('fonts/GothamLight.svg#GothamLight') format('svg');
    font-weight: normal;
    font-style: normal;

}

body {

    font-family: 'GothamLight', sans-serif !important;
    font-size: 16px !important;
    font-weight: 500 !important;
     -webkit-font-smoothing: subpixel-antialiased !important;

}

我已经在谷歌上搜索并寻找答案 - 我已经尝试了所有这些,但似乎没有一个有效。有什么我想念的吗?

【问题讨论】:

    标签: css wordpress font-face font-size


    【解决方案1】:

    为您要使用的每种字体粗细指定字体:

    @font-face {
    font-family: 'GothamLight';
    src: url('fonts/GothamLight.eot');
    src: url('fonts/GothamLight.eot') format('embedded-opentype'),
         url('fonts/GothamLight.woff2') format('woff2'),
         url('fonts/GothamLight.woff') format('woff'),
         url('fonts/GothamLight.ttf') format('truetype'),
         url('fonts/GothamLight.otf') format('opentype'),
         url('fonts/GothamLight.svg#GothamLight') format('svg');
    font-weight: normal;
    font-style: normal;
    }
    
    @font-face {
    font-family: 'GothamLight';
    src: url('path/to/weight500font');
    src: url('path/to/weight500font') format('embedded-opentype'),
         url('path/to/weight500font') format('woff2'),
         url('path/to/weight500font') format('woff'),
         url('path/to/weight500font') format('truetype'),
         url('path/to/weight500font') format('opentype'),
         url('path/to/weight500font') format('svg');
    font-weight: 500;
    font-style: normal;
    }
    

    【讨论】:

      【解决方案2】:

      看起来这与您在 CSS 中的权重混淆以及 webkit-font-smoothing 相结合有关。 “轻”字体通常是 300 粗细,然后您尝试以 500 粗细进行渲染。我可以想象许多浏览器都在“仿粗体”字体。我怀疑 Wordpress 有一些字体平滑/粗细覆盖。

      我建议删除您的 font-weight: 500webkit-font-smoothing 属性并从那里开始。如果您想要 500 粗细的字体,我还建议您找到 Gotham 的 500 粗细 - 如果存在的话。如果没有,我建议不要尝试强制浏览器使用它!

      【讨论】:

        猜你喜欢
        • 2017-09-27
        • 1970-01-01
        • 2011-04-27
        • 2012-02-23
        • 2014-02-12
        • 2016-06-05
        • 1970-01-01
        • 2013-02-21
        • 2016-06-06
        相关资源
        最近更新 更多