I am using Bootstrap to build a menu. When the page is resized for small screens I get my hamburger icon and it shows all items in the menu. Is there a way to hide one item from that menu? I don't want my Cart to show up under the hamburger. I could write some jQuery code myself to do that, but I am wondering if Bootstrap already has a way to do that?
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navMain" aria-expanded="false" aria-controls="navMain"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
<button type="button" class="navbar-toggle btn-lg"> <span class="sr-only">Shopping Cart</span> <span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> </button>
<a class="navbar-brand" href="#">Title</a> </div>
<!-- end navbar-header -->
<div id="navMain" class="navbar-collapse collapse">
<div class="navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> Cart </a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">A</a></li>
<li><a href="#">B</a></li>
</ul>
</li>
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">My Account <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li>
<div class="row" style="width: 400px;">
<ul class="list-unstyled col-md-3" role="menu">
<li><a href="#">A</a></li>
<li><a href="#">B</a></li>
</ul>
<ul class="list-unstyled col-md-3" role="menu">
<li><a href="#">A</a></li>
<li><a href="#">B</a></li>
</ul>
</div>
</li>
</ul>
</li>
</ul>
</div>
<div class="navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Option X <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">A</a></li>
<li><a href="#">B</a></li>
</ul>
</li>
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Option Y <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">A</a></li>
<li><a href="#">B</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Option Z</a></li>
</ul>
</div>
</div>
<!-- end navMain -->
</div>
<!-- end container-fluid -->
</nav>
<!-- end container-fluid -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
If you want to change the visibility of your menu items on the go you just need to set a member variable in your activity to remember that you want to hide the menu and call invalidateOptionsMenu() and hide the items in your overridden onCreateOptionsMenu(...) method.
From the drop-down menu, select the mobile menu you created earlier. Next, you need to scroll down to the 'Hide Original Theme Menu' section. This is where you can tell the plugin to hide a mobile menu created by your WordPress theme.
Selecting Your Mobile Menu Style To select your mobile menu style simply log into your WordPress dashboard then go to Appearance > Customize > Header > Mobile Menu.
It's pretty easy if you use the Bootstrap responsive utility classes hidden-*
classes. In your case, add hidden-xs
to the button.
<button type="button" class="navbar-toggle btn-lg hidden-xs">
Example: http://www.bootply.com/44PQOE3vg1
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