Programming tutorial – in this tutorial I will share about how to create cool search box form in the navbar bootstrap, the search box form useful for reducing limitations of place on the navbar bootstrap. Display search box form will look like the following picture
This Navbar is running well on fixed top navbar bootstrap
Let’s begin the tutorial
Table of Contents
Create new navbar bootstrap like below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | <nav class="navbar navbar-default navbar-fixed-top"> <div class="container-fluid"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Brand</a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> <li><a href="#">Link</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">Action</a></li> <li><a href="#">Another action</a></li> <li><a href="#">Something else here</a></li> <li role="separator" class="divider"></li> <li><a href="#">Separated link</a></li> <li role="separator" class="divider"></li> <li><a href="#">One more separated link</a></li> </ul> </li> </ul> </div> <!-- /.navbar-collapse --> <div class="container searchbardiv" id="formsearch"> <form role="search" method="get" id="searchform" > <div class="input-group"> <input type="text" id="searchbox" class="form-control" name="s" id="s"> <div class="input-group-btn"> <button class="btn btn-default" id="searchsubmit" type="submit"> <strong>Search</strong> </button> </div> </div> </form> </div> </div> <!-- /.container-fluid --> <button type="button" class="buttonsearch" id="buttonsearch"> <i class="glyphicon glyphicon-search openclosesearch"></i><i class="glyphicon glyphicon-remove openclosesearch" style="display:none"></i> </button> </nav> <div class="jumbotron"> <h1>Hello guys,</h1> This is example cool search box form in the navbar bootstrap, to get full code and tutorial please visit <a class="btn btn-primary btn-lg" href="https://seegatesite.com" role="button">seegatesite.com</a> </div> |
Then add the following css below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | .searchbardiv{ display: block; position: fixed; background: #7D1935 ; top: 50px; right: 0px; z-index: 1001; width: 100%; max-width: 100%; padding: 10px; margin: 0px; } .buttonsearch{ position: fixed; top :18px; float: right; right: 0px; margin-right: 10px; background-color: transparent; border: 0px; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; } .buttonsearch:hover{ -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; border: 0px; } .buttonsearch:focus{ -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; border: 0px; } #formsearch{ display: none; } .glyphicon.glyphicon-search { font-size: 18px; } #searchbox { box-shadow: none; padding: 8px 14px; } #searchbox:hover { box-shadow: none; } .form-control:focus { border-color: #ccc; } .navbar-toggle { margin-right: 35px; border: none; background: transparent !important; } .navbar-toggle:hover { background: transparent !important; } .navbar-toggle .icon-bar { width: 22px; transition: all 0.2s; } .navbar-toggle .top-bar { transform: rotate(45deg); transform-origin: 10% 10%; } .navbar-toggle .middle-bar { opacity: 0; } .navbar-toggle .bottom-bar { transform: rotate(-45deg); transform-origin: 10% 90%; } .navbar-toggle.collapsed .top-bar { transform: rotate(0); } .navbar-toggle.collapsed .middle-bar { opacity: 1; } .navbar-toggle.collapsed .bottom-bar { transform: rotate(0); } |
So the search button can run a well, add the jquery function as below
1 2 3 4 5 6 7 | $('#buttonsearch').click(function(){ $('#formsearch').slideToggle( "fast",function(){ $( '#content' ).toggleClass( "moremargin" ); } ); $('#searchbox').focus() $('.openclosesearch').toggle(); }); |
Finish, you can use these tutorial create search box navbar above to beautify your pages. Please see demo on the button below
Bad Live Demo Tutorials
bad live ? sory i dont understand.. the demo live work perfectly !! sorry if it disappoints you