Html 字体系列 Open Sans 不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32508598/
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
Font family Open Sans not working
提问by Stéphane
I'm using Open Sans fontfor my website but it is not working across all computer and I can't figure it why.
我在我的网站上使用Open Sans 字体,但它不能在所有计算机上运行,我不知道为什么。
I'm calling it in my <head>
tag. I tried https
or http
or //
and the result is the same.
我在我的<head>
标签中调用它。我想https
还是http
和//
,结果是一样的。
<link href='//fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,700italic,400,600,700' rel='stylesheet' type='text/css'>
It is well loaded from the browser (status 200).
它可以从浏览器很好地加载(状态 200)。
My CSS looks like this:
我的 CSS 看起来像这样:
body{
font-family: OpenSans;
}
But my text are rendered with some sans-serif font besides the fact that it mention Open Sans in the CSS inspector. Even if I remove all font-family from the CSS inspector in my Chrome browser, the font doesn't change. Also, if I add !important, nothing change.
但是我的文本除了在 CSS 检查器中提到 Open Sans 之外,还使用一些 sans-serif 字体呈现。即使我从 Chrome 浏览器的 CSS 检查器中删除所有字体系列,字体也不会改变。此外,如果我添加 !important,则没有任何变化。
What can be the source of this issue?
这个问题的根源是什么?
I already tried this solutionwithout success.
我已经尝试过这个解决方案但没有成功。
I don't think it's a conflict because it's working on some computer.
我不认为这是冲突,因为它在某些计算机上运行。
回答by Stéphane
Ok, my main error was to use font-family: OpenSans;
instead of font-family: 'Open Sans';
好的,我的主要错误是使用font-family: OpenSans;
而不是font-family: 'Open Sans';
回答by Philip Szalla
did you try to reference your CSS with https?
您是否尝试使用 https 引用您的 CSS?
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,700italic,400,600,700" rel="stylesheet" type="text/css">
I tried this with JSFiddle and it work in my Chrome. https://jsfiddle.net/doqvqfhe/1/
我用 JSFiddle 尝试了这个,它在我的 Chrome 中工作。https://jsfiddle.net/doqvqfhe/1/
Could you give some more code?
能多给点代码吗?
回答by Chinh Vo Wili
I use font-family "Open Sans", It works instead of "OpenSans".
我使用字体系列“Open Sans”,它可以代替“OpenSans”。