Unique Example with CSS Snippet
Here's a straightforward example along with some CSS:
.mynav {
margin-top: 36px;
}
li {
margin: 18px 0;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7b1914140f080f091a0b3b4e554b554b56191e0f1a4a">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cba9a4a4bfb8bfb9aabb8bfee5fbe5fbe6a9aebfaafa">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
<button data-bs-toggle="collapse" data-bs-target="#collapseNav" aria-expanded="false" aria-controls="collapseNav">
BURGER
</button>
<ul class="mynav navigation collapse show" id="collapseNav" style="">
<li>
a
</li>
<li>
b
</li>
<li>
c
</li>
<li>
d
</li>
<li>
e
</li>
</ul>
The Issue at Hand
While animating, notice how the top margins of ul
and li
are no longer collapsing as expected.
Is this intentional behavior? What can be done to overcome this? Could there potentially be a bug in bootstrap 5 causing this?
Update: Solution Found
To resolve this issue, it seems necessary to place all collapsible elements within a wrapper-container. The reason behind this requirement remains unclear to me.
One additional problem arises from this solution: The container may not be an HTML custom element. I suspect this might be a bug. As a result, I have submitted a bug report here: https://github.com/twbs/bootstrap/issues/32828
Nevertheless, this is just a minor observation.