search bar animation

How we can create an expanding search bar using HTML CSS JS? Solution: See this Search Bar Animation With CSS and jQuery, Expanding Bar From Icon.

Previously I have shared an SVG Search Input animation, this is similar to that but it is without SVG shapes. Basically, every website has a specific input to search for items in the whole website. And most of the time search bar placed at top of the webpage along with the navbar. The search element can be simple input, rectangular bar, rounded-rectangular bar, expanding, etc.

Today you will learn to create an expanding search bar from an icon. Basically, there is a search icon and when you will click then it will expand to a search bar. The search icon has two elements, a circle and a line these two things make a complete search icon. On click, the line will hide and the circle becomes a box and expands. The search bar contains a cross button to close the bar and becomes the search icon again. The whole process has a cool and smooth animation.

So, Today I am sharing Search Bar Animation With CSS and jQuery. There I have used HTML to create the input, CSS for styling and creating shapes, jQuery to functioning. This is a cool and unique animated search input, which is ready to use. You can use this search bar on your website, for better design and user attraction.

If you are thinking now how this search bar animation actually is, then see the preview given below.

Preview Of Expanding Bar From Icon

See this video preview to getting an idea of how this animation looks like.

Live Demo

Now you can see this program visually, also you can see it live by pressing the button given above. If you like this, then get the source code of its.

You May Also Like:

Search Bar Animation With CSS and jQuery Source Code

Before sharing source code, let’s talk about it. First I have created a form as the main element and placed other items inside it. Inside the form, I have placed a text input <input type="text"> with ID/Class names and a button. The input is for the bar and the button to reset the bar. Also in the HTML file, I have linked other files like CSS, JS, and jQuery CDN.

Now using CSS I have placed all the items in the right place, as you can see in the preview. With CSS first I gave basic values like size, position, padding, margin, etc to all the elements. I have created the icons using CSS content:"" command, there I did not use any library or SVG shape. I used transform command to making changes and transition command to create animations.

jQuery handling here the toggle expand and close the search input in the program. There I have fetched the search input and button using document.getElementById command. And used input.classList.toggle command to expand and close. Left all other things you will understand after getting the codes, I can’t explain all in writing.

For creating this program you have to create 3 files. First file for HTML, second for CSS, and the third file for JavaScript. Follow the steps to creating this program without any error.

index.html

Create an HTML file named ‘index.html‘ and put these codes given below.

style.css

Now create a CSS file named ‘style.css‘ and put these codes given here.

function.js

The final step, create a JavaScript file named ‘function.js‘ and put the codes.

That’s It. Now you have successfully created Search Bar Animation With CSS and jQuery, Expanding Bar From Icon. If you have any doubt or question comment down below.

Thanks For Visiting, Keep Visiting.

LEAVE A REPLY

Please enter your comment!
Please enter your name here