是否可以使用scss从目录中导入字体? [英] Is it possible to import fonts from the directory with scss?
问题描述
我有一个以这种方式实现字体导入的 scss 文件:
I have a scss file with font import implemented this way:
@import url(https://fonts.googleapis.com/css?family=PT+Sans+Caption:400,700&subset=latin-ext,cyrillic);
我知道使用 CDN 可以为用户提供缓存优势,但这是内部站点,它可以在服务器上使用而无需访问 wide web
.而且我不确定用户机器是否也可以访问 Internet.所以我想为其他页面的静态文件服务.
I understand that using CDN gives advantages in caching for user but this is internal site and it could be used on server without access to the wide web
. And I'm not sure that user machine will have access to the Internet too. So I want to serve fronts with other pages static files.
SCSS 有没有办法从服务器上的某个目录导入字体?类似的东西:
Is there a way in SCSS to import fonts from the some directory on server? Something like:
@import dir(/path/to/fonts/file)
或者SCSS没有这个功能?
Or SCSS has not this feature?
推荐答案
据我所知,您无法在 SCSS 中使用 @import
导入字体.您可以使用 @font-face
包含字体.例如:
As far as I know you can't import fonts using @import
in SCSS. You can include fonts using @font-face
. For example:
@font-face {
font-family: 'Open Sans';
src: url(path/to/file) format(Example: 'truetype' or 'opentype' depending on the file extension of your font);
}
// USAGE
body {
font-family: 'Open Sans', sans-serif;
}
这篇关于是否可以使用scss从目录中导入字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!