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 11 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

<div id="searchwrapper"><form action="">
<input type="text" class="searchbox" name="s" value="" />
<input type="image" src="THE_BLANK_SUBMIT_BUTTON_IMAGE" class="searchbox_submit" value="" />
</form>
</div>

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.

Feel free to reply here :)

Posted by zen   @   8 June 2009 11 comments
Tags : , , ,


  - 11 Comments


Darren says:

My day got a hundred times
better after finding this article.

Thanks for posting this!

Dindigul says:

Very useful. Thank you so much !
.-= Dindigul´s last blog ..Flash News =-.

Kish says:

Hi,

Very Very thanks. It helped me a lot for developing my new version of site for Topincoupons.com

Once again very thanks,
Keep your good work.

Kish says:

Hi,

Very Very thanks. It helped me a lot for developing my new version of site for Topincoupons.com

Once again very thanks,
Keep your good work.
.-= Kish´s last blog ..Save $50 when you spend $250 or more =-.

Rich says:

Do you have a live sample of it anywhere?

I’d love the test it out in a few browsers.

Cheers

zen says:

@Rich, in fact all my premium themes have it , eg : http://zenverse.net/?themedemo=exult

Felix says:

Great tutorial. exactly what i needed.
Thanks

inno says:

this is fantastic !

Sana says:

Hey, it worked great in other browsers but in IE7, the image “.search_submit” is grayed with asterisks. on the whole, great tutorial…

Pedro says:

Great tutorial… where can I get the script to have this work on a site, will this mask Google’s search box?

I appreciate any help thanks!!

zen says:

I am not sure because as I know, we are not allowed to edit any codes given by google, it is against the TOS.

Leave a Reply

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Please wrap all source codes with [code][/code] tags. Powered by Source Codes in Comments
Previous Post
« A Levels Final Exam
Next Post
Vector Brushes 01 – Free Photoshop Brush Set »