SASS variables not parsing correctly - Undefined variable: “$ct-white”

牧云@^-^@ 提交于 2019-12-29 01:28:08

问题


I am using SASS for the first time, and my variables seem to have stopped working. I have the following code in my application.css.scss file:

*= require_self
*/
@import "layout";
@import "colors";
...
@import "text";

In my partial _colors.css.scss file, there is:

...
$ct-white: #F8F8F8 !global;

and in my partial _layout.css.scss file (the Rails default layout file):

/* Site-wide layout syntax */
body {
  background-color: $ct-white;
}

I know that the _layout.css.scss file is loading because other styles on the page work fine when I set body { background-color: #F8F8F8; }. For some reason, the variable isn't being parsed correctly.

Any ideas why?


回答1:


You're importing colors after layout , so the variables you define in colors are not available for layout. You could simply invert the order of those two lines. In SASS, import order matters.




回答2:


If you're using the sass-rails gem, it uses sass 3.2.0 so !global throws an error.



来源:https://stackoverflow.com/questions/25816511/sass-variables-not-parsing-correctly-undefined-variable-ct-white

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!