我正在尝试为我测试的网站添加本地字体。它叫做“AcrosstheRoad.ttf”,可以在我的assets/fonts/文件夹中找到。我正在尝试使用以下代码将其读入CSS文件:
@font-face {
font-family: 'AcrosstheRoad';
src: url('assets/fonts/AcrosstheRoad.ttf') format('truetype');
}
我希望将它用作某种标题类型,因此我正在使用
h3{
font-family: 'AcrosstheRoad';
color: #333;
}
但不幸的是,字体没有加载进来。有人知道我做错了什么吗?
谢谢! Christina
@font-face { font-family: 'AcrosstheRoad'; src: url('/assets/fonts/AcrosstheRoad.woff2') format('woff2'), url('/assets/fonts/AcrosstheRoad.woff') format('woff'), url('/assets/fonts/AcrosstheRoad.ttf') format('truetype'); } h3{ font-family: 'AcrosstheRoad'; color: #333; }
- Christinacss
文件在assets/css/whatever.css
中,那么你可以通过将字体的路径设置为../fonts/AcrosstheRoad.ttf
来纠正问题。 - Adam Jenkinshttp://something.tld/assets/fonts/AcrosstheRoad.ext
吗? - Katherine