Having multiple two-class selectors for a single declaration block, is it possible to simplify the following (i.e. not having to repeat the body
tag):
body.shop, body.contact, body.about, body.faq {background-color:#fff;}
SASS/SCSS code to select multiple select classes in the same item. In SCSS, parent selector & symbol is used. This & will be resolved side by side after compilation for CSS.
We aren't limited to only two here, we can combine as many classes and IDs into a single selector as we want.
There are different methods for combining CSS selectors: Descendant (whitespace) combinator, (Level 1) Child combinator, (Level 2) Next sibling combinator, (Level 2)
Use the getElementsByClassName method to get elements by multiple class names, e.g. document. getElementsByClassName('box green') . The method returns an array-like object containing all the elements that have all of the given class names.
try this:
body{ &.shop, &.contact, &.about, &.faq { background-color:#fff; } }
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