My website includes a List Group created with Bootstrap 4
HTML
<ul class="list-group">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class="list-group-item">Morbi leo risus</li>
<li class="list-group-item">Porta ac consectetur ac</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
CSS
.list-group-item:first-child {
border-top-left-radius: 0.8rem;
border-top-right-radius: 0.8rem;
}
.list-group-item:last-child {
border-bottom-left-radius: 0.8rem;
border-bottom-right-radius: 0.8rem;
}
I have implemented a simple script to toggle the 'd-none' class on elements within this list, but I'm facing an issue where the CSS border radius is affected by the hidden elements.
This results in the bottom corners never being rounded as expected because even the hidden child elements are considered in the styling.
https://i.sstatic.net/MkU7z.png
Specifically, Line 3 and 4 are hidden using .d-none. I want the CSS to round the bottom corners of Line 2 since it is the last visible child.
Is there a way to temporarily remove the nodes with JavaScript so that they do not impact the CSS styling?