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;
}
I believe you need to move that inside the curly braces for logo.
Like this:
# logo {
float: left;
...
&:hover {
color: color;
}
}
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....
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With