I have a navbar that I want to center the menu li items when it collapses.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b9dbd6d6cdcacdcbd8c9f98c978b978b">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="myNav">
<div class="collapse navbar-collapse">
<ul class="navbar-nav ms-auto me-4 my-3 my-lg-0">
<li class="nav-item"><a class="nav-link me-lg-3">Menu Item 1</a></li>
<li class="nav-item"><a class="nav-link me-lg-3">Menu Item 2</a></li>
</ul>
</div>
</nav>
My initial solution involved using div elements within the list items, however this is not valid HTML.
<ul class="navbar-nav ms-auto me-4 my-3 my-lg-0">
<div class="d-flex flex-row justify-content-center">
<li class="nav-item"><a class="nav-link me-lg-3">Menu Item 1</a></li>
</div>
<div class="d-flex flex-row justify-content-center">
<li class="nav-item"><a class="nav-link me-lg-3">Menu Item 2</a></li>
</div>
</ul>
Although this workaround does center the items, it is not the correct way to achieve this in HTML.
Any suggestions on how to properly center the menu items in the collapsed navbar?