css - scss按不同条件导入变量

标签 css sass

我想从Card.scss导入变量,但一直报错:

Undefined variable: "$card-width".

如何正确导入变量?

卡片.scss

@mixin small-card {
  $card-width: 100px;
  $card-height: 200px;
}
@mixin big-card {
  $card-width: 300px;
  $card-height: 600px;
}

TypeACard.css

@import '../../Card.scss';
@include small-card;
.card {

  width: $card-width;
  height: $card-height;
}

TypeBCard.css

@import '../../Card.scss';
@include big-card;

最佳答案

更改为@import '../../Card.scss';

如果仍然无法正常工作,则目录很可能是错误的,祝你好运。

关于css - scss按不同条件导入变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43037137/

相关文章:

javascript - 如何将 HTML 页面添加到 React 应用程序

css - HTML 电子邮件文本被剪裁

javascript - 如何检测新元素何时添加到 jquery 中的文档中?

css - 当博客标题长度不同时如何使用 flexbox 使元素对齐

reactjs - create-react-app 2.0,如何在sass/scss文件中使用绝对路径导入?

css - 可以删除 GWT 生成的 HTML 中的所有类前缀吗?

html - 错误 : Invalid CSS after "body ": expected selector or at-rule, 是第 4 行的 "{"

javascript - 使用CSS定位元素

sass - grunt-contrib-sass 编译单个文件和目录

html - 在WordPress子主题中覆盖父CSS的媒体查询