@font-face问题
我以前做过这个,但还没有掌握。我从 fontsquirrel.com 下载了一个字体工具包,并尝试让我的自定义字体在我的网站上运行。我尝试了很多变体,包括网上找到的“防弹”方法,但现在我自己都感到困惑了。有人可以查看下面的代码并向我展示如何使用 @font-face 正确获取自定义字体以在网站上工作吗?
我有一个名为 fonts.css 的样式表,位于名为 css 的文件夹中。这用于调用自定义字体。字体文件位于根目录下名为fonts的文件夹中。
样式表 fonts 的 css 是:
@font-face {
font-family: 'BebasNeueRegular';
src: url('../fonts/bebasneue-webfont.woff') format('woff'),
url('../fonts/bebasneue-webfont.ttf') format('truetype'),
url('../fonts/bebasneue-webfont.webfontABYyK1dn') format('svg');
font-weight: normal;
font-style: normal;
用于布局等的其他样式表这样调用字体:
}
#merchandise h1 {
font-family: "Bebas Neue", Arial, Helvetica, sans-serif;
font-size: 33px;
font-weight: normal;
line-height: normal;
text-transform: uppercase;
letter-spacing: 1px;
}
有什么明显的吗?当然,它可以在我的机器上本地运行,因为我安装了字体。
I have done this before, but still haven't mastered it. I downloaded a font kit from fontsquirrel.com and tried to get my custom font to work on my site. I have tried so many variations including the "bullet proof" methods found online that I have now confused myself. Could someone look at the code below and show me how to correctly get a custom font to work on a website using @font-face?
I have a style sheet named fonts.css located in a folder named css. This is being used to call the custom font. The font files are located in a folder from the root named fonts.
The css for the style sheet fonts is:
@font-face {
font-family: 'BebasNeueRegular';
src: url('../fonts/bebasneue-webfont.woff') format('woff'),
url('../fonts/bebasneue-webfont.ttf') format('truetype'),
url('../fonts/bebasneue-webfont.webfontABYyK1dn') format('svg');
font-weight: normal;
font-style: normal;
The other styles sheets for layout, etc call the font like this:
}
#merchandise h1 {
font-family: "Bebas Neue", Arial, Helvetica, sans-serif;
font-size: 33px;
font-weight: normal;
line-height: normal;
text-transform: uppercase;
letter-spacing: 1px;
}
Anything obvious? Of course, it works locally on my machine because I have the font installed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
#merchandise h1
中,font-family: "Bebas Neue"
需要为font-family: "BebasNeueRegular"
或
在
@font-face
中,font-family: 'BebasNeueRegular'
需要为font-family: 'Bebas Neue'
In
#merchandise h1
,font-family: "Bebas Neue"
needs to befont-family: "BebasNeueRegular"
or
In
@font-face
,font-family: 'BebasNeueRegular'
needs to befont-family: 'Bebas Neue'