Answer the question
In order to leave comments, you need to log in
How to set multiple properties for multiple elements but within the same id?
How to simplify access to elements?
<div>
<div class="main1">
<div class="sub1">
Block 1
</div>
<div class="sub2">
Block 2
</div>
<div class="sub3">
Block 3
</div>
</div>
<br>
<div class="main2">
<div class="sub1">
Block 5
</div>
....
</div>
</div>
.main1 .sub1 {color:red}
.main1 .sub2 {color:red}
.main1 .sub3 {color:red}
/* или */
.main1 .sub1, .main1 .sub2, .main1 .sub3 {color:red}
.main1 {
.sub1 {color:red}
.sub2 {color:red}
.sub2 {color:red}
}
Answer the question
In order to leave comments, you need to log in
In SCSS this is easily solved via @extends
:
%subsclasses-color {
.sub1, .sub2, .sub3 {
color:red;
}
}
.main1 {
@extends %subclasses-color;
}
.another-main {
@extends %subclasses-color;
}
<div class="main1">
<div class="sub"></div>
<div class="sub"></div>
<div class="sub"></div>
</div>
<div class="main2">
<div class="sub"> </div>
<div class="sub"> </div>
<div class="sub"> </div>
</div>
.main1 {
.sub { color: red }
}
.main2 {
.sub { color: blue }
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question