【问题标题】:Sass outputs default file even with changed variables即使变量改变,Sass 也会输出默认文件
【发布时间】:2020-06-26 15:57:50
【问题描述】:

我正在尝试为我的自定义版本的 Bootstrap 更改一些变量。现在我有 Bootstrap SCSS 文件和我自己的变量文件。我的文件如下所示:

@import "/path/to/bootstrap";
$blue:    #42a5f5;
$indigo:  #5c6bc0;
more styles here…

但是,当我运行 sass /path/to/custom.scss /path/to/output.css 时,它仍然会输出默认的 Bootstrap 文件,如下所示:

:root {
  --blue: #007bff;
  --indigo: #6610f2;
more styles here…

为什么会这样?

【问题讨论】:

    标签: css twitter-bootstrap command-line sass bootstrap-4


    【解决方案1】:

    根据Bootstrap 4

    同一个 Sass 文件中的变量覆盖可以在默认变量之前或之后。但是,在跨 Sass 文件进行覆盖时,您的覆盖必须在您导入 Bootstrap 的 Sass 文件之前进行。

    由于您创建了自己的 custom.scss 文件,它应该如下所示:

    // Your variable overrides
    $blue:    #42a5f5;
    $indigo:  #5c6bc0;
    
    // Bootstrap and its default variables
    @import "/path/to/bootstrap";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-25
      • 2018-01-20
      • 2015-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-25
      • 2017-10-26
      相关资源
      最近更新 更多