我在从子域加载字体时遇到问题。
我想将它们托管在地址类似 http://static.mydomain.com/fonts 的 ftp 上.
然后我想从几个子站点加载它:http://subsite1.mydomain.com和 http://subsite2.mydomain.com .
问题是:如果我包含具有这样的 font-face 属性的字体:
@font-face {
font-family: NeutonBold;
src: url('http://static.mydomain.com/fonts/Neuton-Bold.ttf');
}
然后我从浏览器收到这个安全错误:
Font from origin '...' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '...' is therefore not allowed access.
我真的很想避免在所有子站点上重复字体...
这可能吗?
感谢您的帮助!
最佳答案
看看如果将 font-family: 放在下面会发生什么,如下所示:
@font-face {
src: url('http://static.mydomain.com/fonts/Neuton-Bold.ttf');
font-family: NeutonBold;
}
关于css - 如何为我的字体制作一个 cdn?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37523019/