My code looks the same as this page:
https://getbootstrap.com/docs/3.3/examples/navbar/
When I open the page in mobile, it looks like this:
But when I open it on Desktop, it looks like this:
How can I force the page to look the same on Desktop as it does on Mobile?
i.e. I want a hamburger menu on the desktop version of the site.
Things I have tried
I set a max-width=480px
on the outer div
on the page, but that didn't help.
I have also posted a related question on the softwarerecs SE (https://softwarerecs.stackexchange.com/questions/51989/a-css-framework-which-is-essentially-a-mobile-only-unresponsive-version-of-boo), which BTW I think is silly (libraries are intrinsic to programming and library questions should be allowed on SO!).
Hamburger menus might be a great solution for mobile devices with limited screen space, however, translating the same mobile-first design into your desktop without any changes may cause a bad user experience. Putting your most important pages in hidden navigation could sabotage them.
Hamburger Menu in Bootstrap is defined as a list of links or buttons or content on the navigation bar hidden or shown simultaneously when we click a button like a triple equal on the right side of the navigation bar. Hamburger menu is nothing but navigation bar.
The hamburger toggler color is controlled by the two inbuilt classes used for changing the color of the content in the navigation bar: . navbar-light: This class is used to set the color of the navigation bar content to dark.
A Hamburger Menu is a way to display navigation links on a website, usually for mobile devices and smaller screens. However, CSS hamburger menus can be used for desktop websites as well. Once you click the “hamburger” icon, a sliding menu will appear, displaying on top of the main content.
Here's a css-only example. Full credit to the original author.
HTML
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-header">
<a class="navbar-brand" href="#">Brand</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
<div class="navbar-header navbar-right">
<p class="navbar-text">
<a href="#" class="navbar-link">Username</a>
</p>
</div>
</div>
</nav>
CSS
body {
padding-top:70px;
}
.navbar-header {
float: none;
}
.navbar-toggle {
display: block;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
}
.navbar-nav>li {
float: none;
}
.navbar-collapse.collapse.in{
display:block !important;
}
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