Files
30-seconds-of-code/snippets/zebra-striped-list.md
Angelos Chalaris 43a3dbcc08 Update covers
2023-02-16 22:24:33 +02:00

687 B

title, tags, cover, firstSeen, lastUpdated
title tags cover firstSeen lastUpdated
Zebra striped list visual forest-balcony 2018-10-31T08:19:06+02:00 2020-12-30T15:37:37+02:00

Creates a striped list with alternating background colors.

  • Use the :nth-child(odd) or :nth-child(even) pseudo-class selectors to apply a different background-color to elements that match based on their position in a group of siblings.
  • Note: You can use it to apply different styles to other HTML elements like <div>, <tr>, <p>, <ol>, etc.
<ul>
  <li>Item 01</li>
  <li>Item 02</li>
  <li>Item 03</li>
  <li>Item 04</li>
  <li>Item 05</li>
</ul>
li:nth-child(odd) {
  background-color: #999;
}