I've attempted to add a unique style to all divs with the same class within a parent div, except for the last one. Strangely, my code doesn't seem to work as expected for this particular case. Can anyone spot what I might be overlooking? Right now, it is simply applying a 24px bottom margin to all instances of StyledDiv
const StyledDiv = styled.div`
width: 100%;
margin-bottom: 24px;
display: flex;
flex-direction: column;
&:last-child {
margin-bottom: 0;
}
`;
<div>
<StyledDiv className='childDiv'>
<p>Hello World 1</p>
</StyledDiv>
<StyledDiv className='childDiv'>
<p>Hello World 2</p>
</StyledDiv>
<div>
<p>Some other text and not a styled div</p>
</div>
</div>