I've written this code, but it does not work. What is my problem?
.class { margin:20px; :hover { color:yellow; } }
To solve the issue, you need to go over the CSS hover code to establish if you use the right selector. As well, ensure you use an opening curly bracket ({) after each selector and a closing curly bracket (}) at the end of the property list.
Nesting is a shortcut to creating CSS rules. Nesting in SASS works as selector of multiple CSS and combine them within one another instead of writing different CSS lines just to be precise about the style that we want to add to an element, we just nest it up.
SASS (Syntactically Awesome Style Sheets) is a pre-processor scripting language that will be compiled or interpreted into CSS. SassScript is itself a scripting language whereas SCSS is the main syntax for the SASS which builds on top of the existing CSS syntax.
For concatenating selectors together when nesting, you need to use the parent selector (&
):
.class { margin:20px; &:hover { color:yellow; } }
You can easily debug such things when you go through the generated CSS. In this case the pseudo-selector after conversion has to be attached to the class. Which is not the case. Use "&".
http://sass-lang.com/documentation/file.SASS_REFERENCE.html#parent-selector
.class { margin:20px; &:hover { color:yellow; } }
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