我的代码有问题。因为我想在我的页面中包含一个全局字体,并且我下载了一个.ttf文件。我把它包含在我的主CSS中,但是我的字体不会改变。
下面是我的简单代码:
@font-face {
font-family: 'oswald';
src: url('/font/oswald.regular.ttf');
}
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin:0;
padding:0;
border:0;
font-size:100%;
font:inherit;
font-family: oswald;
vertical-align:baseline
}
我不知道我哪里错了。你能帮我做这个吗?谢谢。
发布于 2014-07-28 07:46:44
你试过格式化了吗?
@font-face {
font-family: 'The name of the Font Family Here';
src: URL('font.ttf') format('truetype');
}
阅读本文:http://css-tricks.com/snippets/css/using-font-face/
此外,可能还取决于浏览器。
发布于 2018-10-11 12:40:05
你可以像这样使用font face:
@font-face {
font-family:"Name-Of-Font";
src: url("yourfont.ttf") format("truetype");
}
发布于 2020-02-14 03:43:32
我知道这是一个老帖子,但这解决了我的问题。
@font-face{
font-family: "Font Name";
src: url("../fonts/font-name.ttf") format("truetype");
}
请注意,src:url("../fonts/font-name.ttf");
我们使用两个句点返回根目录,然后进入fonts文件夹或您的文件所在的任何位置。
希望这能帮助某些人:)快乐的编码
https://stackoverflow.com/questions/24990554
复制相似问题