diff --git a/snippets/zebra-striped-list.md b/snippets/zebra-striped-list.md new file mode 100644 index 000000000..93642598c --- /dev/null +++ b/snippets/zebra-striped-list.md @@ -0,0 +1,41 @@ +### Zebra striped list + +Creates a striped list with alternating background colors, which is useful for differentiating siblings that have content spread across a wide row. + +#### HTML + +```html + +``` + +#### CSS + +```css +li:nth-child(odd) { + background-color: #eee; +} +``` + +#### Demo + + +#### Explanation + +1. Use the `:nth-child(odd)` or `:nth-child(even)` pseudo-class to apply a different background color to elements that match based on their position in a group of siblings. + +Note that you can use it to apply different styles to other HTML elements like div, tr, p, ol, etc. + +#### Browser support + +✅ No caveats. + +https://caniuse.com/#feat=css-sel3 + + +