【发布时间】:2021-10-29 13:41:27
【问题描述】:
试图理解为什么 SASS 在 CSS 中编译错误:
在 _typography.scss 我有:
@mixin fontType ($type) {
@if $type=="normal" {
@font-face {
font-family: "gotham";
font-weight: normal;
font-style: normal;
src: url("./assets/fonts/HomepageBaukasten-Book1/BOOK/WEB/HomepageBaukasten-Book.woff2");
}
} @else {
@font-face {
font-family: "gotham";
font-weight: bold;
font-style: normal;
src: url("./assets/fonts/HomepageBaukasten-Bold11/BOLD/WEB/HomepageBaukasten-Bold.woff2");
}
}
}
在 main.scss 中:
@import "./abstracts/typography";
body {
@include fontType("normal");
background-color: $background-color;
line-height: 1.6;
}
并像这样在 main.css 文件中编译:
body {
background-color: #17141f;
line-height: 1.6;
}
@font-face {
body {
font-family: "gotham";
font-weight: normal;
font-style: normal;
src: url("/HomepageBaukasten-Book.1c60130f.woff2");
}
}
知道问题出在哪里吗?我在某个地方出错了吗? TY
【问题讨论】:
-
一切看起来都像我希望它从您编写的 SASS 中看到的那样。 CSS 无效,因为
@font-face声明中没有选择器。
标签: css sass scss-mixins