Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base-level rules cannot contain the parent-selector-referencing character '&'

Tags:

sass

I'm flowing the ROR 4 tutorials , There is a chapter mentioned about Compiling Sass to CSS . I modified (#logo:hover and #footer:hover) to & :hover But error occurred

Base-level rules cannot contain the parent-selector-referencing character '&'.
 (in/Users/snailwalker/rails_projects/sample_app/app/assets/stylesheets/custom.css.scss:54)

My SCSS:

/* header */
#logo {
  float: left;
  margin-right: 10px;
  font-size: 1.7em;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: -1px;
  padding-top: 9px;
  font-weight: bold;
  line-height: 1;
}
& :hover {
  color: #fff;
  text-decoration: none;
}
like image 485
gqli Avatar asked Aug 28 '14 17:08

gqli


2 Answers

I believe you need to move that inside the curly braces for logo.

Like this:

# logo {
    float: left;
    ...
  &:hover {
    color: color;
  }
}
like image 108
VCavallo Avatar answered Sep 28 '22 18:09

VCavallo


Your & has to be nested inside of a css/scss rule so:

.my_class {
    css-rule: value;
    another-css-rule: value;

    &:hover {
        css-hover-rule: value;
    }
 }

The way you have it Sass doesnt know what the & is for. The above is the same as having:

.my_class {
    some rules.....
}

.my_class:hover {
    some hover rules....
}
like image 22
GifCo Avatar answered Sep 28 '22 16:09

GifCo