jquery - Modifying Bootstrap Navbar -
am trying modify bootstrap navbar display links(list item) on different media screen, example on navbar list have list including search , login/signup list items, on phone or tablet want display search , login/signup list items , navbar-brand, instead of showing navbar-brand , collapsing lists item, have tried different methods e.g excluding search , login/signup list items dropdown list etc. still not working.
here html code css bootstrap css(bootstrap.css). , please me, if can without bootstrap well. view working code on jsbin.
or
<nav class = "navbar navbar-inverse"> <div class = "navbar-header"> <button type = "button" class = "navbar-toggle" data-toggle = "collapse" data-target = "#mynav"> <span class = "icon-bar"></span> <span class = "icon-bar"></span> <span class = "icon-bar"></span> </button> <a href = "#" class = "navbar-brand">stack ask</a> </div> <div class = "collapse navbar-collapse" id = "mynav"> <ul class = "nav navbar-nav"> <li class = "active"><a href = "#">home</a></li> <li><a href = "#">education</a></li> <li class = "dropdown"><a class = "dropdown-toggle" data-toggle = "dropdown" href = "#">tutorials <span class = "caret"></span> </a> <div class = "dropdown-menu"> <ul class = "nav navbar-nav"> <li><a href = "#">programming languages</a></li> <li><a href = "#">web development</a></li> </ul> </div> </li> <li><a href = "#">kingdom centre</a></li> <li><a href = "">about</a></li> </ul> <ul class = "nav navbar-nav navbar-right"> <li class = "dropdown"><a href = "#" class = "dropdown-toggle" data-toggle = "dropdown"><span class = "glyphicon glyphicon-search"></span> search</a> <div class = "dropdown-menu"> <ul class = "nav navbar-nav"> <li> <form class="form-search"> <div class = "container-fluid"> <input type="text" class="form-control input-medium search-query" style = "border-radius: 25px;" /> <button type="submit" class="btn" style = "margin-top: 10px; margin-left: 5px;">search</button> </div> </form> </li> </ul> </div> </li> <li><a href = "#"><span class = "glyphicon glyphicon-user"></span> sign up</a></li> <li><a href = "#"><span class = "glyphicon glyphicon-log-in"></span></span> log in</a></li> </ul> </div> </nav>
well alternatively can make use of hidden-xs
, hidden-sm
, hidden-md
, hidden-lg
class show , hide particular ul
's, perhaps need make copy of ul
!! updated code below: bin here
.mob-nav>li { float:left }
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <nav class = "navbar navbar-inverse"> <div class = "navbar-header"> <button type = "button" class = "navbar-toggle" data-toggle = "collapse" data-target = "#mynav"> <span class = "icon-bar"></span> <span class = "icon-bar"></span> <span class = "icon-bar"></span> </button> <a href = "#" class = "navbar-brand">stack ask</a> <ul class = "mob-nav hidden-sm hidden-md hidden-lg nav navbar-nav "> <li class = "dropdown"><a href = "#" class = "dropdown-toggle" data-toggle = "dropdown"><span class = "glyphicon glyphicon-search"></span> search</a> <div class = "dropdown-menu"> <ul class = "nav navbar-nav"> <li> <form class="form-search"> <div class = "container-fluid"> <input type="text" class="form-control input-medium search-query" style = "border-radius: 25px;" /> <button type="submit" class="btn" style = "margin-top: 10px; margin-left: 5px;">search</button> </div> </form> </li> </ul> </div> </li> <li><a href = "#"><span class = "glyphicon glyphicon-user"></span> sign up</a></li> <li><a href = "#"><span class = "glyphicon glyphicon-log-in"></span></span> log in</a></li> </ul> </div> <div class = "collapse navbar-collapse" id = "mynav"> <ul class = "nav navbar-nav"> <li class = "active"><a href = "#">home</a></li> <li><a href = "#">education</a></li> <li class = "dropdown"> <a class = "dropdown-toggle" data-toggle = "dropdown" href = "#">tutorials <span class = "caret"></span> </a> <div class = "dropdown-menu"> <ul class = "nav navbar-nav"> <li><a href = "#">programming languages</a></li> <li><a href = "#">web development</a></li> </ul> </div> </li> <li><a href = "#">kingdom centre</a></li> <li><a href = "">about</a></li> </ul> <ul class = "hidden-xs nav navbar-nav navbar-right"> <li class = "dropdown"><a href = "#" class = "dropdown-toggle" data-toggle = "dropdown"><span class = "glyphicon glyphicon-search"></span> search</a> <div class = "dropdown-menu"> <ul class = "nav navbar-nav"> <li> <form class="form-search"> <div class = "container-fluid"> <input type="text" class="form-control input-medium search-query" style = "border-radius: 25px;" /> <button type="submit" class="btn" style = "margin-top: 10px; margin-left: 5px;">search</button> </div> </form> </li> </ul> </div> </li> <li><a href = "#"><span class = "glyphicon glyphicon-user"></span> sign up</a></li> <li><a href = "#"><span class = "glyphicon glyphicon-log-in"></span></span> log in</a></li> </ul> </div> </nav>
Comments
Post a Comment