"Bootsnipp Navbar with Search"
Bootstrap 3.3.0 Snippet by rosiered999

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
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<nav class="[ navbar navbar-fixed-top ][ navbar-bootsnipp animate ]" role="navigation">
<div class="[ container ]">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="[ navbar-header ]">
<button type="button" class="[ navbar-toggle ]" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="[ sr-only ]">Toggle navigation</span>
<span class="[ icon-bar ]"></span>
<span class="[ icon-bar ]"></span>
<span class="[ icon-bar ]"></span>
</button>
<div class="[ animbrand ]">
<a class="[ navbar-brand ][ animate ]" href="#">Bootsnipp</a>
</div>
</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 navbar-right ]">
<li class="[ visible-xs ]">
<form action="http://bootsnipp.com/search" method="GET" role="search">
<div class="[ input-group ]">
<input type="text" class="[ form-control ]" name="q" placeholder="Search for snippets">
<span class="[ input-group-btn ]">
<button class="[ btn btn-primary ]" type="submit"><span class="[ glyphicon glyphicon-search ]"></span></button>
<button class="[ btn btn-danger ]" type="reset"><span class="[ glyphicon glyphicon-remove ]"></span></button>
</span>
</div>
</form>
</li>
<li><a href="#" class="[ animate ]">About</a></li>
<li>
<a href="#" class="[ dropdown-toggle ][ animate ]" data-toggle="dropdown">Resources <span class="[ caret ]"></span></a>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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
.animate {
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.navbar-bootsnipp {
background-color: rgb(255, 255, 255);
border-color: rgb(95, 176, 228);
border-radius: 0px;
margin-bottom: 0px;
z-index: 100;
}
.navbar-bootsnipp:nth-of-type(2) {
border-top-width: 1px;
z-index: 50
}
.navbar-bootsnipp.affix-top {
position: absolute;
top: 0px;
width: 100%;
}
.navbar-bootsnipp.affix {
top: 0px;
width: 100%;
}
.navbar-bootsnipp .navbar-toggle .icon-bar {
background-color: rgb(95, 176, 228);
}
.navbar-bootsnipp .navbar-brand {
color: rgb(95, 176, 228);
font-weight: 900;
letter-spacing: 2px;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$(function() {
$('a[href="#toggle-search"], .navbar-bootsnipp .bootsnipp-search .input-group-btn > .btn[type="reset"]').on('click', function(event) {
event.preventDefault();
$('.navbar-bootsnipp .bootsnipp-search .input-group > input').val('');
$('.navbar-bootsnipp .bootsnipp-search').toggleClass('open');
$('a[href="#toggle-search"]').closest('li').toggleClass('active');
if ($('.navbar-bootsnipp .bootsnipp-search').hasClass('open')) {
/* I think .focus dosen't like css animations, set timeout to make sure input gets focus */
setTimeout(function() {
$('.navbar-bootsnipp .bootsnipp-search .form-control').focus();
}, 100);
}
});
$(document).on('keyup', function(event) {
if (event.which == 27 && $('.navbar-bootsnipp .bootsnipp-search').hasClass('open')) {
$('a[href="#toggle-search"]').trigger('click');
}
});
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: