content logo

Bootstrap Search Boxes:

Bootstrap Search Box in Header with Options

Have you ever tried to add in a new feature to your website but decided not to because it cluttered your pages and you did not want to waste too much physical space on such features? In these cases, you may choose to simply go for more important features such as a search box since they are more commonly used and more useful overall. But what if we said you can have the search box and another feature without using any space on the actual web page?! You can always have a Bootstrap search bar in a sidebar or a navigation bar to help avoid cluttering your pages.

In this post, we have a CSS search bar which is mainly located at the top of the screen in an expandable menu. You can open the menu to see the search bar in which you can type in what you need to find and the system will find it for you. It also has a filter button (the cog icon) which helps you speed up the process of finding different titles. You can do an advance search with this search bar by name and colour. This Bootstrap advance search box has a black, grey and turquoise colour theme.

#

Advance Search

#

Bootstrap Search Bar

#

Bootstrap Advance Search

#

CSS Search Bar


<!-- This script got from frontendfreecode.com -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <a class="navbar-brand" href="#">Magic Search</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">API</a>
            </li>
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    Resources
                </a>
                <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                    <a class="dropdown-item" href="#">Bootstrap</a>
                    <a class="dropdown-item" href="#">Timely Systems</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="#">Jquery Help</a>
                </div>
            </li>
        </ul>
        <form class="form-inline my-2 my-lg-0">
            <div class="input-group">
                <div class="input-group-prepend">
                    <select class="btn btn-secondary" id="inputGroupSelect02">
                        <option selected>Options</option>
                        <option value="name">Name</option>
                        <option value="color">Color</option>
                        <option value="cmc">CMC</option>
                        <option value="sets">Set</option>
                    </select>
                    <button class="btn btn-info" type="button" data-toggle="modal" data-target="#advanced_search"><i class="material-icons">settings</i></button>
                </div>
                <input type="text" class="form-control" aria-label="Text input with dropdown button" />
                <div class="input-group-append">
                    <button class="btn btn-info" type="button" id="search_submit"><i class="material-icons">search</i></button>
                </div>
            </div>
        </form>
    </div>
</nav>
<div class="modal fade" id="advanced_search" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Advanced Search</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <input type="text" class="advanced_search form-control" id="advanced_name" aria-describedby="emailHelp" placeholder="Name" />
                </div>
                <div class="form-group">
                    <input type="text" class="advanced_search form-control" id="search_color" placeholder="Color" />
                </div>
                <button type="search" class="btn btn-info btn-block" id="search_submit">Search</button>
            </div>
        </div>
    </div>
</div>
<br />
<div class="container">
    <div class="row">
        <div class="d-flex flex-wrap justify-content-center">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        </div>
    </div>
</div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
.navbar {
    box-shadow: 0 0 7px black;
}
.card {
    border: none;
}
.search {
    border-radius: 0px;
    width: 3em;
    background-color: transparent;
    border: 0px;
}
.search:focus {
    border-color: transparent;
    border-radius: 0px;
    background-color: transparent;
    border: 0px;

    color: white;
}
.material-icons {
    vertical-align: middle !important;
}
.justify-content-center {
    padding: 14px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<style>
.navbar {
    box-shadow: 0 0 7px black;
}
.card {
    border: none;
}
.search {
    border-radius: 0px;
    width: 3em;
    background-color: transparent;
    border: 0px;
}
.search:focus {
    border-color: transparent;
    border-radius: 0px;
    background-color: transparent;
    border: 0px;

    color: white;
}
.material-icons {
    vertical-align: middle !important;
}
.justify-content-center {
    padding: 14px;
}
</style>

</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <a class="navbar-brand" href="#">Magic Search</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">API</a>
            </li>
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    Resources
                </a>
                <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                    <a class="dropdown-item" href="#">Bootstrap</a>
                    <a class="dropdown-item" href="#">Timely Systems</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="#">Jquery Help</a>
                </div>
            </li>
        </ul>
        <form class="form-inline my-2 my-lg-0">
            <div class="input-group">
                <div class="input-group-prepend">
                    <select class="btn btn-secondary" id="inputGroupSelect02">
                        <option selected>Options</option>
                        <option value="name">Name</option>
                        <option value="color">Color</option>
                        <option value="cmc">CMC</option>
                        <option value="sets">Set</option>
                    </select>
                    <button class="btn btn-info" type="button" data-toggle="modal" data-target="#advanced_search"><i class="material-icons">settings</i></button>
                </div>
                <input type="text" class="form-control" aria-label="Text input with dropdown button" />
                <div class="input-group-append">
                    <button class="btn btn-info" type="button" id="search_submit"><i class="material-icons">search</i></button>
                </div>
            </div>
        </form>
    </div>
</nav>
<div class="modal fade" id="advanced_search" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Advanced Search</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <input type="text" class="advanced_search form-control" id="advanced_name" aria-describedby="emailHelp" placeholder="Name" />
                </div>
                <div class="form-group">
                    <input type="text" class="advanced_search form-control" id="search_color" placeholder="Color" />
                </div>
                <button type="search" class="btn btn-info btn-block" id="search_submit">Search</button>
            </div>
        </div>
    </div>
</div>
<br />
<div class="container">
    <div class="row">
        <div class="d-flex flex-wrap justify-content-center">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        </div>
    </div>
</div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>

</body>
</html>
Preview