The user dropdown in my code is cut off, even though I'm using Bootstrap 5. I came across an older article on stackoverflow suggesting to add .dropdown-menu-left
or .dropdown-menu-right
to the </ul>
, but that didn't solve the issue for me.
I believe a solution would be to position my dropdown to the bottom left of the User link. Below, I have included the source code, perhaps a bit extensive, but it might be necessary to see the entire nav
.
https://i.sstatic.net/I6TCr.png
Notice how the dropdown menu is being cut off to the right.
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-lg">
<a class="navbar-brand" href="{{ url_for('index') }}">
<img src="../static/logo.png" alt="" width="30" height="24" class="d-inline-block align-text-top">
Homepage
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" href="/blog">Blog</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-bs-toggle="dropdown"
aria-expanded="false">Username
</a>
<ul class="dropdown-menu" aria-labelledby="userDropdown">
<li><a class="dropdown-item" href="/logout">Log Out</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>