There is an element in this code snippet:
<div>
<li>
item 1
</li>
<li>
item 2
</li>
<li>
item 3
</li>
<li>
item 4
</li>
</div>
I always want to display the first two items, so I used the following CSS:
li {
&:nth-child(1),
&:nth-child(2) {
display: none;
}
}
However, if another item gets added, then the visible items will be the last two. Is there a way to always show only two items? Do I need to modify my CSS?