How to Create a 3D Search Bar in HTML / CSS

P On 20 Feb, 2012 • + By 9 With 11 Comments

WordPress Portfolio Themes

Search bar are one of the essential component of a website, if you have thousands among thousands of post, you really need to put a search bar on your homepage or sidebar. And if your search bar is a little boring, users tend to look somewhere else, so you need to put a little bit of effort on creating your search bar, you can use cool Jquery autocomplete or some animation.

View the demo here.

You can download the HTML zip at the bottom of this tutorial!

Today we will bring to life the 3D search bar that we did in the past, this tutorial will help you to start everything from scratch. I think this is a good way to practice your skills in HTML and CSS.

How to Create a 3D Search Bar in HTML / CSS - Sanjay Khemlani

View the demo here

If you missed the PSD tutorial you can go here, and make sure you download the PSD (we will wait for you). Now that you’re back we will start the slicing part, we will only slice two image then we will code it. Easy ;)

Slicing the PSD

How to Create a 3D Search Bar in HTML / CSS - Sanjay Khemlani

On the 3d Search Bar PSD. Click the eye beside the layer on text ,layer 0 and button, this will make them invisible on the canvas.

How to Create a 3D Search Bar in HTML / CSS - Sanjay Khemlani

You will now have a clean input field like this. Now crop it and save it as png.

How to Create a 3D Search Bar in HTML / CSS - Sanjay Khemlani

Next is the buttons, what we did is duplicate the folder button and inside that folder, move the button-shadow layer 1px above. Crop it as little space as possible and same format as above. You can even grab this image :)

Code the 3D Search Bar

Now you can close Photoshop and open your code editor, we will start to code the search bar.

You can see that I’ve commented all of the div’s, this is a good practice when creating a html. The only important part here is the.

Now we will use the images that we sliced. We will use CSS to achieve this.

Let me break down the CSS for you, first we called the background of our entire search bar.

Next is we style our input field, and keep it align with the background using float and margin. Finally giving it the CSS rounded corners so we won’t see any flaws on the design.

On our submit button, we used the CSS technique called CSS Sprite (read more about it on CSS-Tricks). We use the images as background but cut the upper part by using height, aligning them using float and margin. Cursor changes the pointer to a hand, just thought you should know :)

Upon hovering the button, the image position will go up by -55px. That’s the exact height of the upper button.

If you wanted to learn more about this push button effect, this tutorial will explain it better for you.

And we are done with the coding, easy isn’t? :) You can use this on your WordPress themes or HTML Projects, you can also add new interactive design on your search bar.

Creating such simple design combined with CSS will give us endless possibilities on creating new way of designing our site, whether for clients or personal use. I suggest that you should follow good practice while learning so you’ll have a solid ground when you mature as a designer.

C Tags: , , ,

Show some love and share!

Join our 356 subscribers and get the tutorials right from your inbox!

*I will not send spam message or affiliate offers.

I design / build Custom Wordpress Themes for different kinds of Clients, big or small, solo-prenuers or marketer. I've also worked with different design agencies as their 'web guy' for their Clients. I also enjoy writing tutorials and helping newbies so I can contribute to the community. Got a project in mind? Let's talk! | More about me?

11 Responses to “How to Create a 3D Search Bar in HTML / CSS”

  1. Vishwas Kumar says:

    Very Nice…………

  2. chanhope says:

    thanks nice tutorial :)

    but your twitter tittle made me think tht ur going to make a 3d search box only with HTML 5 n CSS3 ( i mean without ny images)

    • sanjay says:

      Glad you like it chanhope, sorry if that’s the case bu I didn’t mention html5 / css3. Maybe I’ll do another post about that, thanks for the idea :)

  3. Beben Koben says:

    nice one, use image right?
    ty for coding m/

  4. Hey Sanjay, I have found your blog while touring in the blog land and I was searching for some CSS tutorials. I have got your blog post, after finding your blog, believe me or not, I could not take my eyes off. Great post mate, great tutorial. Even I have also done this for one of my website. Thanks for sharing and looking forward to more great tips from you. Keep it up. :)

  5. Thank you very good indeed.

  6. Ronak says:

    nice work on that…!!!!

  7. Prithvi says:

    A nice tutorial.. Really a lot to grab from this post.. Keep up the good work man. :)

Leave a Reply