为什么该资源(字体)的绝对路径不起作用,而相对路径却起作用?
<body>
hello friend
</body>
<style type="text/css">
@font-face {
font-family: 'Gilroy';
/* src: url("../src/styles/assets/Gilroy.otf"); */
src: local('Gilroy')
url('/Users/username/dev-env/test-react/app/src/styles/assets/Gilroy.otf');
}
body {
font-family: Gilroy;
}
</style>
答案 0 :(得分:1)
您在,
之后缺少local()
<style type="text/css">
@font-face {
font-family: 'Gilroy';
src: local('Gilroy'),
url('/Users/username/dev-env/test-react/app/src/styles/assets/Gilroy.otf');
}
body {
font-family: Gilroy;
}
</style>