To create a search bar in the navigation bar is easy, just like building another choice in the navbar that will search the database. You need to be careful about the timing of placing the search bar. Make sure separately placed in the navbar. To create a navbar receiving a search bar you will need HTML and CSS. The below explanation will guide you stepwise on how to create a search bar. This article contains 2 sections in the first region we will attach the CDN link for icon and will make a basic structure. The next section will invent the navbar and the search bar in it.
Creating Structure: In this section, we will just create the basic site structure and also attach the CDN link of the Font-Awesome for the icons which will be used as a search icon in the bar.
HTML
Before we start writing code first, we need to create a primary structure of the HTML document, so that the browser can understand and start working. The basic HTML structure looks like the following.
After writing the primary structure of the HTML document, you will also write the tags and content you need. After that, you can see the output in your browser. We know that HTML Sudu Mae is used for exposing content in a basic format. To complete our content we need to use CSS, which is an HTML insert and it creates an engaging user interface.
<!DOCTYPE html>
<html>
<head>
<title>how to create navigration bar with Search box</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="nav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">News</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Event</a></li>
<li><a href="#">about</a></li>
<li>
<input type="text" name="Searchbox" class="Search" placeholder="Search Hare">
</li>
</ul>
</div>
</body>
</html>
CSS
Now, we have time to improve the HTML content, for that, we need to add CSS to the HTML file. CSS can be added to HTML documents in a total of three ways, here we are using outside CSS design using CSS will arrive here after typing and see the output in your browser.
margin: 0;
background-color: #abb5bf;
}
.nav{
width: 100%;
background-color: #133a5d;
overflow: auto;
}
ul{
padding: 0;
margin: 0;
list-style: none;
}
li{
float: left;
}
a{
color: white;
}
a:link{
width: 130px;
display: block;
padding: 15px;
text-decoration: none;
font-family: vardana;
font-size: 20px;
text-align: center;
text-transform: uppercase;
}
.Search{
width: 300px;
padding: 5px;
border-radius: 0 10px 10px 0;
border:none;
border: 1px solid blue;
font-size: 17px;
text-align: center;
margin-top: 13px;
}
Source Code
No comments: