Responsive Navbar with Search Box using HTML CSS & JavaScript

CodingNepal
3 min readJun 19, 2020
Responsive Navbar with Search Box using HTML CSS & JavaScript
Responsive Navbar with Search Box using HTML CSS & JavaScript

Hello readers, Today in this blog, you’ll learn how to create a Fully Responsive Navbar with Search using HTML CSS & JavaScript. Earlier I have shared many blogs about Responsive Navigation Bar and Responsive Sidebar Menu but still, I have not shared any blog on Responsive Navbar with Search Box. So now, it’s time to create Responsive Navbar with Search Box.

A navigation bar is a user interface element within a webpage that contains links to other parts of the website. A website navigation bar is most usually displayed as a horizontal list of links at the top of each page.

Today in this blog, I’ll share with you this program (Responsive Navbar with Search Box). This navbar is fully responsive to any device. On mobile devices, this navbar will adjust its height-width automatically according to the device's height-width. I used CSS Flex and @media property to make this Navbar Fully Responsive. The search box of this navbar is to create only for design purposes so, when you entered any info in the search bar and click on the search button, it won’t show you any results.

If you’re feeling difficult to understand what I am saying. You can watch a full video tutorial on this program (Responsive Navbar with Search Box).

Video Tutorial of Responsive Navbar with Search Box

As you have seen in the video, this Navbar is fully Responsive for any device. If you’re a beginner in Web Designing then this tutorial helped you to understood the basic codes and concepts behind creating the Responsive Navbar and their Search Box.

If you like this program (Responsive Navbar with Search Box) and want to get source codes. You can easily get the source codes of this program. To get the source codes you just need to scroll down. You can use this program on your projects and websites. If you know JavaScript perfectly then you can easily make this search box workable by adding some JavaScript codes.

Responsive Navbar with Search Box [Source Codes]

As always, before sharing the codes of this program (Responsive Navbar with Search Box). Let’s a few talks about the main tags and codes of this program. At first, In the HTML File, I created <nav> tag. As you know, the <nav> tag highly used to create Navbar. Then I created a <div> with the class name “.logo”. After that, I created another <div> with the class name “nav-items” and placed five <li> tags inside it. Inside each <li> tag I created <a> anchor tag.

Inside href attribute of <a> tag, I’ve written # which means when you click on the nav items it won’t redirect you to any page. If you want to redirect your user to a particular page then you can put the URL of the page inside the href. At last, I created <form> and placed <input> tag and <button> tag. Inside <button> I’ve written the class name of the font-awesome search icon name to show Search Icon.

In the CSS File, first I gave a background-color to the navbar then using flex property I placed all elements horizontally. Then I did basic styling to logo and nav-items like I gave color, font-size, padding, etc. Similarly, after that, I did styling to the search box and search icon. Then I again created some tags in HTML File for icons (cancel, menu, search) and hide these icons with giving display: none.

Now, to make this navbar responsive I used CSS @media property. Using this property I’ve changed the elements height-width, margin-padding, size, etc. at particular width. On mobile devices, I moved the logo at the center and placed all nav-items vertically and changed the position of Search Box, and did basic styling to it. In JavaScript, I just created a three-click function for Cancel, Menu, and Search Button. Then I changed the CSS values of Navbar and Search box on the particular button clicked.

You can download the source code files through the given link. Click here to download source code files.

You might like this:

Animated Sidebar Menu Design
Responsive Dropdown Menu Bar
Responsive Sidebar Menu Design
Responsive Navbar with Searchbox

Originally published at https://www.codingnepalweb.com on June 19, 2020.

--

--

CodingNepal

CodingNepal is a blog where we post blogs related to HTML, CSS, JavaScript & PHP along with creative coding stuff.