Currently, I am working on a navigation bar that includes a "nav-item" with a dropdown function.
My goal is to make the clickable button/nav-item visible in the navbar redirect to another page, while having the dropdown arrow appear on the right side. You should be able to click on the arrow to access the dropdown menu.
I have explored two approaches:
1.
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" />
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="../Startseite/Index.jsp">Home <i class="fas fa-home"></i></a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="../Gruppen/index.html" id="navbardrop1">Groups <i class="fas fa-users"></i></a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#group1">Group 1</a>
<a class="dropdown-item" href="#group2">Group 2</a>
<a class="dropdown-item" href="#group3">Group 3</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="../Payments/payments.html">Payments <i class="fas fa-receipt"></i></a>
</li>
</ul>
</div>
</nav>
This design fits what I am aiming for, but I would prefer to have the "Groups" element clickable to redirect to a different page.
2.
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" />
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="../Startseite/Index.jsp">Home <i class="fas fa-home"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../Gruppen/index.html">Groups <i class="fas fa-users"></i></a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbardrop1" data-toggle="dropdown"></a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#group1">Group 1</a>
<a class="dropdown-item" href="#group2">Group 2</a>
<a class="dropdown-item" href="#group3">Group 3</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="../Payments/payments.html">Payments <i class="fas fa-receipt"></i></a>
</li>
</ul>
</div>
</nav>
The second solution seems messy in my opinion, and I am looking for a cleaner approach. As someone new to HTML, Bootstrap, and CSS, I wonder if there's a better way to achieve the desired outcome.
EDIT: Curiously, after running both code snippets on my local server, I noticed a variation in the output. I prefer the layout of the second approach without having the arrow as a separate navitem, but when implemented, the dropdown arrow appears above all other elements in the navbar. Is there a fix for this issue?