如何将外部字体加载到HTML文档中? [英] How do I load external fonts into an HTML document?
问题描述
例如:
将文本等等等等等等字体从一个TTF文件在同一目录下使用HTML CSS和/或JAVASCRIPT
看看这个 A List Apart文章。相关的CSS是:
@ font-face {
font-family:Kimberley;
src:url(http://www.princexml.com/fonts/larabie/kimberle.ttf)格式(truetype);
h1 {font-family:Kimberley,sans-serif}
<以上将在Chrome / Safari / FireFox中使用。正如Paul D. Waite在评论中指出的那样,如果将字体转换为 EOT格式。好消息是,这似乎在旧的浏览器中优雅地退化,所以只要你意识到并且舒适的事实,并不是所有的用户都会看到相同的字体,这是安全的使用。
How do I load external font files into an HTML document.
Example: Make the text "blah blah blah blah blah blah blah" a custom font from a TTF file in the same directory using HTML CSS and/or JAVASCRIPT
Take a look at this A List Apart article. The pertinent CSS is:
@font-face {
font-family: "Kimberley";
src: url(http://www.princexml.com/fonts/larabie/kimberle.ttf) format("truetype");
}
h1 { font-family: "Kimberley", sans-serif }
The above will work in Chrome/Safari/FireFox. As Paul D. Waite pointed out in the comments you can get it to work with IE if you convert the font to the EOT format.
The good news is that this seems to degrade gracefully in older browsers, so as long as you're aware and comfortable with the fact that not all users will see the same font, it's safe to use.
这篇关于如何将外部字体加载到HTML文档中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!