在css中使用自定义字体时出错
虽然我尝试通过 CSS 文件为我的网站使用自定义字体,但我没有获得所需的字体,并且仅显示默认字体。请检查 css 代码,如果需要任何更改,请告诉我:)
@font-face {
font-family: Myriad Pro;
src: url('Myriad.ttf');
}
#voicetext{
color:#127bb9;
font-size:16px;
font-family:"Myriad Pro";
text-align:center;
letter-spacing:3px;
}
While I tried to use custom font for my website through the CSS file, I'm not getting the required font and it shows only the default font. Please Check the css code and let me know if any changes needed :)
@font-face {
font-family: Myriad Pro;
src: url('Myriad.ttf');
}
#voicetext{
color:#127bb9;
font-size:16px;
font-family:"Myriad Pro";
text-align:center;
letter-spacing:3px;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,它并不像这样简单。对于真正的跨浏览器解决方案,您需要参考的不仅仅是 TTF 版本。
这个问题:How to embed fonts in HTML? 有一个完整的列表,并且指向 Paul Irish 的“Bulletproof Web 字体” 博客条目的链接,该博客条目可满足您的需求针对所有浏览器的怪癖。
如果您赶时间,并且对具体细节不感兴趣,FontSquirrel 的 Bulletproof @font-face 生成器 似乎利用了博客文章中的提示。
Unfortunately, it isn't as straight forward as this. For a truly cross-browser solution, you will need to reference more than just the TTF version.
This question: How to embed fonts in HTML? has a full list, and links to Paul Irish's "Bulletproof web fonts" blog entry that caters for all the browser quirks.
If you're in a hurry, and not interested in the specifics, FontSquirrel's Bulletproof @font-face generator seems to utilize the hints from the blog post.
我的第一个猜测可能是您将字体文件上传到了错误的位置。
目前,您需要将 Myriad.ttf 文件放在与 css 文件相同的目录中。
My first guess is probably that you've uploaded your font file at the wrong place.
Currently, you'll need a Myriad.ttf file in the same directory as your css file.