I'm having trouble getting the nth-child or nth-of-type selectors to take effect in a list of divs.
I'm working in a React app and have a component representing a single item in a collection that renders the following HTML structure:
<div className="link-row">
<div className="link-row-header-container">
<div className="header-name"></div>
<div className="header-info"></div>
</div>
<div className="link-container">
<div className="left-inner-container"> //this is the container i'm trying to select
</div>
<div className="right-inner-container">
</div>
</div>
<div className="link-row-footer-container">
<span> footer stuff </span>
</div>
</div>
I have a function in an outer component mapping the above component over a collection of data and placing them in a single <div> like so:
<div> {linkList} </div>
I'm trying to alternate the background color of "left-inner-container" in sequences of threes, but I'm consistently getting only a single color across all of them.
Here's my CSS:
.left-inner-container {
display: flex;
justify-content: center;
align-items: center;
width: 50px;
height: 50px;
border-right-style: solid;
border-right-width: 2px;
border-right-color: #450037;
}
.left-inner-container:nth-of-type(3n+1) {background-color: #ff5e39;}
.left-inner-container:nth-of-type(3n+2) {background-color: #00d2d1;}
.left-inner-container:nth-of-type(3n+3) {background-color: #ffffff;}