【问题标题】:OpenSansSemiBold seems unavailable on localhostOpen Sans SemiBold 似乎在 localhost 上不可用
【发布时间】:2015-06-02 23:51:56
【问题描述】:

我最近一直在大修我的前端代码以使用 Stylus 而不是 CSS。大多数情况下它都没问题,但现在无论我使用字体OpenSansSemiBold,它看起来就像浏览器的默认字体。即使我在 Chrome 开发人员工具中手动添加 font-family: 'OpenSansSemiBold' 属性,它也不会更改为正确的字体,而这样做适用于我当前部署的网站实时版本。知道什么可能会阻止找到此字体吗?

编辑:我在本地使用 nginx(与现场相同)。 Google 的字体是在导入预处理 CSS 的位置上方导入的,如下所示:

<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,800' rel='stylesheet' type='text/css'>

【问题讨论】:

  • 在您的实时网站上,您是否链接到谷歌字体?你在离线测试你的本地网站吗?你是如何将字体添加到页面的?
  • 如果您在没有服务器的情况下在 HTML 中进行测试,请确保您使用的是 http://fonts.googleapis.com 而不是 //fonts.googleapis.com。也可能有助于显示您的代码...
  • 感谢您的提问,我已详细更新了我的问题。

标签: css fonts stylus font-family


【解决方案1】:

根据 Google 字体,您在定义字体时应该使用 font-family: 'Open Sans', sans-serif;

<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,800' rel='stylesheet' type='text/css'>

<style>
body {
    font-family: 'Open Sans', sans-serif;
}
</style>

<!-- define as bold -->
<strong>Lorem ipsum dolor sit amet, consectetur adipisicing elit, </strong>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-18
    • 2012-06-02
    • 2016-08-08
    • 2015-12-07
    • 2014-10-21
    • 1970-01-01
    • 2014-08-31
    • 1970-01-01
    相关资源
    最近更新 更多