Currently, it appears that V4 has no documentation on using navbar dropdowns. Following the the V3 docs, the navbar on V4 does drop down on click, but appears to be unstyled. How can I get the dropdown to appear properly as shown in the V3 docs? I’m assuming that the css selector has changed; if that’s the case, how would I go about finding the new undocumented selector?
This is what it currently looks like with V3 classes on the V4 library:
The HTML used:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.2/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.2/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-fixed-top navbar-dark bg-inverse">
<a class="navbar-brand" href="/">HelloWorld</a>
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">1<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Map</a></li>
<li><a href="#">Grid</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">2<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Map</a></li>
<li><a href="#">Grid</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">3<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Map</a></li>
<li><a href="#">Grid</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link" href="">Test</a></li>
</ul>
<ul class="nav navbar-nav pull-xs-right">
<li class="nav-item"><a class="nav-link" href="">Logout </a></li>
</ul>
</nav>
</body>
</html>
2
Answers
You are using
<li> and <ul>
whereas the documentation suggests to use<div> and <a>
tags insteadEdit: Fiddle for reference
Edit2: Ok so u missed the classes
btn and btn-success
. Also add css rule.dropdown { display:inline-block;}
Edit3: Fiddle Link: Dropdown 1 with
<a>
instead of<button>
Try below:
Working Plnkr: Plnkr