If this is purely the case, I don’t want you to manually type all these selectors, you could use the CSS preprocessor to generate them for you.
http://codepen.io/cimmanon/pen/Hrimz
Sass:
@mixin fat-zebra($rows) {
$collector: ();
@for $r from 1 through $rows {
$collector: append($collector, unquote("&:nth-child(#{$rows * 2}n+#{$r})"), comma);
}
@content;
}
}
td {
@include fat-zebra(3) {
background: yellow;
}
}
Conclusion:
td:nth-child(6n+1), td:nth-child(6n+2), td:nth-child(6n+3) {
background: yellow;
}
More lines?
td {
@include fat-zebra(10) {
background: yellow;
}
}
Conclusion:
td:nth-child(20n+1), td:nth-child(20n+2), td:nth-child(20n+3), td:nth-child(20n+4), td:nth-child(20n+5), td:nth-child(20n+6), td:nth-child(20n+7), td:nth-child(20n+8), td:nth-child(20n+9), td:nth-child(20n+10) {
background: yellow;
}
source
share