Is there a more elegant way to write this?
.standard {
padding-top: 50px;
padding-bottom: 50px;
}
.standard.color-0 + .standard.color-0,
.standard.color-1 + .standard.color-1,
.standard.color-2 + .standard.color-2,
.standard.color-3 + .standard.color-3,
.standard.color-4 + .standard.color-4,
.standard.color-5 + .standard.color-5,
.standard.color-6 + .standard.color-6,
.standard.color-7 + .standard.color-7,
.standard.color-8 + .standard.color-8 {
padding-top: 0;
}
Is there perhaps some selector that checks for matches of the classes found on 2 or more elements without actually knowing the exact class's name? Such as something like:
.standard.color-* + .standard.color-* {
padding-top: 0;
}
What I have currently (posted above) works the way I want it to as far as how it displays on my site, but I am just curious whether, or not, I am doomed to constantly add .standard.color-# + .standard.color-#
for every new color I need (which in for this case are background-colors for full-width <section>
tags).
Examples:
<section class="standard color-0"></section> // top and bottom padding
<section class="standard color-1"></section> // top and bottom padding
-----------------------------------------------------------------------
<section class="standard color-1"></section> // top and bottom padding
<section class="standard color-1"></section> // padding-top: 0; (if both "color-#" is the exact same this loses its top padding)
EDIT: Simplified post and code. <section>
will always have a .standard
class and a .color-
class with .color-0
being background-color: transparent;
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…