【发布时间】:2015-01-19 16:55:29
【问题描述】:
我正在尝试在我的网站上嵌入字体“gothamcondensed”,但它不起作用,我使用了 font-squirrel 中的@font-face。我只是在服务器上移动了我的字体并更改了网址,但它不起作用。
有什么建议吗?我真的需要一个建议。以下是我的代码:
@font-face {
font-family: 'gothamcondensedbold';
src: url('http://some-url.com/zts-fonts/gothamcondensed-bold_0-webfont.eot');
src: url('http://nx3corp.com/zts-fonts/gothamcondensed-bold_0-webfont.eot?#iefix') format('embedded-opentype'),
url('http://nx3corp.com/zts-fonts/gothamcondensed-bold_0-webfont.woff2') format('woff2'),
url('http://nx3corp.com/zts-fonts/gothamcondensed-bold_0-webfont.woff') format('woff'),
url('http://nx3corp.com/zts-fonts/gothamcondensed-bold_0-webfont.ttf') format('truetype'),
url('http://nx3corp.com/zts-fonts/gothamcondensed-bold_0-webfont.svg#gothamcondensedbold') format('svg');
font-weight: normal;
font-style: normal;
} body {
margin:0;
padding:0;
font-family: 'gothamcondensedbold';
}
【问题讨论】:
-
http://some-url.com对于第一个 eot 是否正确?或者这只是一个示例占位符 -
您是否在控制台中遇到错误?类似
No 'Access-Control-Allow-Origin' -
是的,网址是正确的,我可以从 url 下载字体
-
是的,我在控制台中收到以下消息:来自源“some-url.com”的字体已被跨源资源共享策略阻止加载:没有“Access-Control-Allow-Origin”标头出现在请求的资源上。因此,不允许访问 Origin 'null'。
-
不要忘记标记为已解决,无论是自己标记还是从答案中标记(如果它有助于解决您的问题)。