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;}
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;}
try this:
body{
&.shop, &.contact, &.about, &.faq {
background-color:#fff;
}
}
In this case we can use @each
directive:
$pages: shop, contact, about, faq;
body {
@each $page in $pages {
&.#{$page} {
background-color:#FFF;
}
}
}
If you are using sass compiled by the node, that may do.
body {
.shop, .contact, .about, .faq {
background-color:#FFFFFF;
}
}
I am not sure that this directly addresses the question, but with scss
you can reuse two classes in one like this:
.displayFlex {
display: '-webkit-box'; /* OLD - iOS 6-, Safari 3.1-6 */
display: '-moz-box'; /* OLD - Firefox 19- (buggy but mostly works) */
display: '-ms-flexbox'; /* TWEENER - IE 10 */
display: '-webkit-flex'; /* NEW - Chrome */
display: flex; /* NEW, Spec - Opera 12.1, Firefox 20+ */
}
.flexOne {
flex: 1; /* NEW, Spec - Opera 12.1, Firefox 20+ */
-webkit-box-flex: 1; /* OLD - iOS 6-, Safari 3.1-6 */
-moz-box-flex: 1; /* OLD - Firefox 19- */
-webkit-flex: 1; /* Chrome */
-ms-flex: 1; /* IE 10 */
}
.boxWrapper01 {
@extend .displayFlex;
@extend .flexOne;
justify-content: center;
flex-direction: column;
align-items: center;
background-color: beige;
}
Parent child relationship in sass
parent_tag {
.child {
// rules here
}
}
© 2022 - 2024 — McMap. All rights reserved.