Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple two-class selectors in Sass

Tags:

css

sass

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;} 
like image 796
Fellow Stranger Avatar asked Sep 01 '13 18:09

Fellow Stranger


People also ask

How do I select multiple classes in Sass?

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.

Can class selector have multiple classes?

We aren't limited to only two here, we can combine as many classes and IDs into a single selector as we want.

Can you combine multiple CSS selectors?

There are different methods for combining CSS selectors: Descendant (whitespace) combinator, (Level 1) Child combinator, (Level 2) Next sibling combinator, (Level 2)

How do you select an element with multiple classes?

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.


1 Answers

try this:

body{    &.shop, &.contact, &.about, &.faq {         background-color:#fff;     } } 
like image 117
Alessandro Minoccheri Avatar answered Sep 21 '22 22:09

Alessandro Minoccheri