简体   繁体   中英

Sass::SyntaxError in _base.scss

I'm getting a syntax error in my css file in rails.

File name: _base.scss

        body {
        font-size: 15px;
        line-height: 20px;
        color: $grey;
        font-family: $body-font;
          }

Undefined variable: "$grey". (in /home/mali/rails_projects/platform-rails3/app/assets/stylesheets/_base.css.scss)

Any idea why this error comes up and how do I solve it? Thanks in advance. Funny thing is it is working when I include it in view like application:

        <%= stylesheet_link_tag "application" %>

but not working like this:

           <%= stylesheet_link_tag "_base" %>      

Gray (with an a) is a css constant colour (#808080). $grey is a sass variable which has to be defined to hold the colour before you use it.

@import 'main';

at the top of your _base.scss file.

You may want to consider extracting only the colour definitions out to their own scss file (which you @import into everything you need) if there is too much in main that you don't want to include in every sub scss file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM