I have some specific styling defined like this
.activities {
border: 1px solid green;
.activity {
background-color: red;
&:first-child {
background-color: yellow;
}
}
}
I am looking to style the .activity
element that is a first child with a yellow background, only if the parent element with .activities
class does not have the additional class .events
.
In the scenario below, the first .activity
element should maintain a background-color: red
<div class="activities events">
<div class="activity">one</div>
<div class="activity">two</div>
<div class="activity">three</div>
</div>
Are there alternative methods to exclude this first-child styling when the element with class .activities
also contains the class .events
?
or is this the most straightforward solution:
.events .activity:first-child {
background-color: red;
}