javascript - Hide bootstrap navbar on mobile and show a button instead to show the collapsed navbar dropdown -


i use bootstrap navbar, , collapses fine on small screens, shows navbar-toggle , dropdown menu if click on navbar-toggle. standard behavior.

i want, however, hide entire navbar ribbon on small screens , show button on top middle part of screen. when click on button, should open dropdown navbar. html:

<div class="navbar-show">     <button type="button" class="navbar-toggle" onclick="document.getelementbyid('toggle-button').click();">         <img height="50px" width="50px" src="img/logo3.gif">     </button> </div>  <nav class="navbar navbar-default" data-ng-controller="globalauthctrl">    <div class="container-fluid">     <div class="navbar-header">       <button type="button" class="navbar-toggle" id="toggle-button" data-toggle="collapse" data-target="#mynavbar">         <span class="icon-bar"></span>         <span class="icon-bar"></span>         <span class="icon-bar"></span>        </button>       <a class="navbar-brand" href="http://gliderforecast.com"><img height="50px" width="48px" src="img/logo3.gif"></a>     </div>     <div class="collapse navbar-collapse" id="mynavbar">       <ul class="nav navbar-nav"> 

my css:

@media (max-width: 767px) {      .navbar{         display:none;     }     .navbar-show {         display: block !important;     } } .navbar-show {     display: none;     position: fixed;     z-index: 10;     top: 0px;     left: 50%; } 

it shows regular navbar on large screens, hides navbar , shows button on small screens, cannot show collapsed navbar dropdown when click on button. please guide me in right direction. different approach fine, have required functionality. jquery not preferred, (i using angularjs) can use too.

you can delete #toggle-button part. , try:

<div class="navbar-show">     <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mynavbar">         <img height="50px" width="50px" src="img/logo3.gif">     </button>  </div> 

bootstrap links it's js part through data- attributes here.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -