Create a Fancy Search Box using CSS

Post image of Create a Fancy Search Box using CSS
Posted in Design Tips on 8 June 2009 110 comments

Nowadays, most websites come with a search box to improve surfing experience. To make your website looks good, beside having a nice looking theme, you would need a fancy search box to replace the classic ones.

Let’s start

1. Design your own search box


In this example, I will use this as my search box.

2. Crop it out

Make sure the background color outside the search box is the same as your design. Now crop the whole search box out.

result:

3. Create a blank image as submit button


The picture above explained all.

4. HTML codes for the search box

Replace the “THE_BLANK_SUBMIT_BUTTON_IMAGE” with the image at step 3.

5. CSS codes for my search box

#searchwrapper {
width:310px; /*follow your image's size*/
height:40px;/*follow your image's size*/
background-image:url(THE_SEARCH_BOX_IMAGE);
background-repeat:no-repeat; /*important*/
padding:0px;
margin:0px;
position:relative; /*important*/
}

#searchwrapper form { display:inline ; }

.searchbox {
border:0px; /*important*/
background-color:transparent; /*important*/
position:absolute; /*important*/
top:4px;
left:9px;
width:256px;
height:28px;
}

.searchbox_submit {
border:0px; /*important*/
background-color:transparent; /*important*/
position:absolute; /*important*/
top:4px;
left:265px;
width:32px;
height:28px;
}

Basically what’s going on :
#searchwrapper wrap the whole search box, carrying the whole search box image as its background image.
.searchbox is the text area to enter search keyword, given a transparent background and no border.
.searchbox_submit is the submit button, also given a transparent background and no border.

NOTE:
Both .searchbox and .searchbox_submit have been given an absolute position, you should modify their position, width and height according to your own search box.

That’s it.

Hope this helps!

 

Posted by Zen on 8 June 2009 110 comments
Tags : , , ,



or Subscribe to specific category only :




  - 110 Comments


Vinay says:

Thank you so much for the tutorial Buddy.

It was a great resource.

Thanks,
Vinay

Trackbacks

  1. Showcase of Inspiring Search Box Designs - Noupe Design Blog
  2. Showcase of Inspiring Search Box Designs « Downgraf – Design weblog for designers
  3. Campos de búsqueda en HTML y CSS | SummArg
  4. Create a Fancy Search Box using CSS « Kỹ Thuật Lập Trình ASP.NET
  5. Create a Fancy Search Box using CSS | 阿華的小站
  6. Customized Search Box Problems
  7. 10 casute de cautare in CSS « CoolTips
  8. 12 Search Form Tutorials Using CSS3, HTML5 and jQuery for Inspiration | A Web Design-Development Blog

Leave a Reply

You must be logged in to post a comment.

Previous Post
«
Next Post
»