Expanding Search Bar using HTML CSS JQuery

 

Expanding Search Bar using HTML CSS JQuery

Hello Friends, Today, I share a project on expanding search bar animation using HTML, CSS, and jquery. The search box is one of the standard features of any websites nowadays.search bars perform as the gateway of the contents available on your webpage. Using this, the user-friendliness of the website increases. Today we are making a search box animation where if a user clicks on the search icon, the search box will expand but closes again when we click on the same icon.


In this jquery animated search box project, I have used plain HTML, CSS, and a little bit of jquery code to make this fantastic looking expanding search bar. You can watch the demo video below how it will look like after implementing the codes.



I hope you have watched the demo and have some ideas about the project we are going to make today. Let's start with HTML first. The HTML markup for this project plain and straightforward. First, I have taken a div named 'box' and placed an input element and div designated button with a font-awesome search icon. I have used a placeholder text for the input element. For doing this project, I am using font-awesome CDN and jquery CDN. You can download the files from their website and link them as well.

You May Also Like:
First, in the CSS part, I eliminate the default margin padding of the project by a margin and padding of zero to the body element. I provided a black background for the project, but you can choose the color of your choice. Later I offered a particular height and width for the 'box' div and positioned the div in the middle of the project using CSS transform property. I also set a transition for the width of the 'box' element. Then I put a particular width for the search box when it will expand after we click on it. In this case, I put a width of 650px. You can choose your width while you will use it. Then I styled the input element and button div with some basic styling. Later I applied some jquery codes at the end to make it work. when a button is clicked, a click function will occur, and the 'active' class we set previously will start functioning, and the opposite will happen when we click on the button.

Expanding Search Bar ( Source Code ):

to make this snippet, you have to create one HTML and CSS and link the CSS file to your HTML file. After copying the code below and paste them to the respective file and save.

HTML




CSS 




I hope you like the small snippet. Follow our social media profiles to keep connected with this blog, and thanks for visiting the blog.

Please do not enter any spam link in the comment box.

Post a comment

Please do not enter any spam link in the comment box.

Post a Comment (0)

Previous Post Next Post