I'm trying to make my navigation and footer links collapse into a toggle button when the width is decreased, but without making them have the class 'navbar-default' (that class adds another navigation bar to my navigation bar and makes it look ugly).
Here's an example of my header's navigation HTML:
<div class="header" id="header-container">
<div class="container" id="header">
<button class="navbar-toggle collapsed" data-toggle="collapse" data-target="#header-collapse-1"><span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<ul class="nav collapse navbar-collapse nav-pills pull-right" id="header-collapse-1">
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/img/resume.pdf" target="_blank">Resume</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
<h3>TITLE</h3>
</div>
</div>
The navigation buttons disappear but no toggle button appears to open the accordion. Please let me know if there is a workaround to get the toggle button to appear.
Only way i can think of is to add a class to the navbar and create a couple of rules to override navbars for elements only with that class.
Consider adding these 2 rules (and customize the styles as you need):-
.custom-nav-bar.navbar-toggle {
background-color: #ddd; /*Background color for holder*/
}
.custom-nav-bar.navbar-toggle .icon-bar {
background-color: #888; /*Background color for bar in the holder*/
}
and add custom-nav-bar
to the navbar-toggle
element
<button class="navbar-toggle collapsed pull-left custom-nav-bar" data-toggle="collapse" data-target="#header-collapse-1">
.custom-nav-bar.navbar-toggle {
background-color: #ddd;
}
.custom-nav-bar.navbar-toggle .icon-bar {
background-color: #888;
}
<!DOCTYPE html>
<html>
<head>
<script data-require="jquery@*" data-semver="2.1.1" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script data-require="[email protected]" data-semver="3.1.1" src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link data-require="[email protected]" data-semver="3.1.1" rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<div class="header" id="header-container">
<div class="container" id="header">
<button class="navbar-toggle collapsed pull-left custom-nav-bar" data-toggle="collapse" data-target="#header-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse" id="header-collapse-1">
<ul class="nav navbar-nav nav-pills pull-left " >
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/img/resume.pdf" target="_blank">Resume</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With