I am trying to refactor this piece of CSS code using commas so I am not duplicating the same set of rules for every elements. Here I want specific children elements of .clear to be invisible when the class .clear. is toggled.
.clear select {
opacity: 0;
transition: 0.2s;
}
.clear input {
opacity: 0;
transition: 0.2s;
}
.clear p {
opacity: 0;
transition: 0.2s;
}
.clear .section-content {
opacity: 0;
transition: 0.2s;
}
This works, but doesn't look too efficient. From my understanding, commas are used to apply the same set of rules to multiple elements.
.clear select,input,p,.section-content {
opacity: 0;
transition: 0.2s;
}
Now if I refactor this way, no matter if .clear class is toggled or not in my HTML, all element will be invisible.
What would be the correct way to make this work in one set of rules ?