CSS 未使用字体系列 Open Sans

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22908040/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:13:08  来源:igfitidea点击:

Font Family Open Sans not being used

cssfontsfont-family

提问by callmekatootie

I am using Google's Open Sans Fontin my application.

我在我的应用程序中使用Google 的 Open Sans 字体

I have defined the stylesheet as instructed:

我已经按照说明定义了样式表:

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

I then used it on the body selector as:

然后我在 body 选择器上使用它:

body {
    font-family: 'Open Sans', sans-serif;
}

I have not defined font family anywhere else. I assume that since I have defined it at the parent, the child elements will automatically inherit it.

我没有在其他任何地方定义字体系列。我假设因为我已经在父元素中定义了它,所以子元素会自动继承它。

However, if I open up the inspector for say an anchor tag in my application and see the computed styles for that tag, I find that (Chrome Latest) the "Rendered Font" says "Times New Roman 18 glyphs" - Is this correct? I was expecting it to say "Open Sans" - Is the Open Sans font not being applied?

但是,如果我打开检查器以在我的应用程序中说一个锚标记并查看该标记的计算样式,我会发现(Chrome 最新)“渲染字体”显示“Times New Roman 18 glyphs” - 这是正确的吗?我期待它说“Open Sans” - 没有应用 Open Sans 字体吗?

回答by Aalind Sharma

Check out the codepen link. Its working fine for me !

查看codepen 链接。它对我来说很好用!

.open-sans-font{
  font-family: 'Open Sans', sans-serif;
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,700" rel="stylesheet">

<div class="open-sans-font">
   Stackoverflow rocks !!!
</div>