I have encountered an issue with selecting the last list item in a specific case. I have a list of items where only one can be selected at a time, and when selected, it should be displayed at the top of the list using flex ordering. However, I am having trouble ensuring that the last selected item does not have a border. I have tried using various selectors, including
.selection li:not(.selected):last-of-type
, but the last-of-type
selector is not behaving as expected. The problem arises when the last list item is the one selected, resulting in a double border at the bottom of the list instead of a single border coming from the unordered list element.
In my CSS code snippet, you can see the styles I applied and the selector causing the issue. I have also provided a Codepen snippet to demonstrate the problem.
Any insights or suggestions on how to resolve this issue would be greatly appreciated. Thank you for your help!