Hello readers we are back with another interesting post. This post is based on the topic of HTML and CSS.Hope all are doing well and safe. Explore all the contents of our blog and support us.

In this post we are going to learn how to code a animated spinning search bar using HTML and pure CSS.We are going to learn about the appearance of it and how to code it.

What is a search bar?

A search bar is an element in a website that allows you to search the content in the website based on few keywords entered in it. A  search bar helps an user to search the contents in the website.

How does the search bar look like and what does it do?

  • It contains the text box for entering the text.
  • A button with a search icon.
  • On focusing the search bar the text box will spin along X axis and expands .
  • On de-focusing it will again spin in the opposite direction and contracts.

You might like these:


Video for proper understanding.

I have explained the steps involved in coding the search bar . For preview and proper understanding of the code I have provided a youtube video made by me.
 


Source codes:


HTML:



 

The HTML part is quite simple in this case all that matters is the CSS part. Coming to the HTML part I have created a Form with class name set to "animate". Inside this "animate" class all the coding part is written.

The search bar is created through the "input" tag with type="text". Then the styling is done in the CSS part. Then a button of type="submit" is created. Inside the button a search bar icon is created by setting class name to "fa fa-search".  

CSS:

 


The CSS plays a major role in customizing the search bar. Let' discuss about the customization one by one. 

First customizing the text bar. The padding is set to 10px and color to black and font-size is set to 17px and the border to violet. The text bar is made to float left and required background is given.

Here the "transition" property is set to 0.8 seconds for "transform" and for width 1 second is given with a delay of 0.8 seconds. In "width 1s 0.8s", "1s" specifies the duration for transformation of width and  "0.8s" specifies the delay for the width transformation. So that the width will began to increase after the spinning.

On focusing of the search bar few properties are specified. On focusing the bar the box-shadow is set to " 0 2px 0" and the transform property is set to "rotateX(1080deg)" so that the bar would spin 3 times along X axis.

On focusing the search bar the width will increase to 80% with a delay of 0.8 seconds and with a time span of 1 second.

Now the search icon button. It is made to float left, and width to 30px , padding to 10px. The properties like background, font-size and border are specified according to user requirements.


Hope this was helpful.


Thanks for Reading and keep visiting.




Post a Comment

Previous Post Next Post