Amazon Style Search Box using jQuery & CSS

Last modified on by Karthikeyan K

Today I am going to tell you how to create Amazon Style Search Box with filter options using jQuery & CSS code. This tutorial will help you to implement search box with dropdown option in your ecommerce projects like amazon.com
In my previous post. I had explained how to create search box with select option – http://w3lessons.info/2012/11/04/search-box-with-select-option-using-css/

Amazon Style Search Box with jQuery

jQuery Code

  $("#searchDropdownBox").change(function(){
var Search_Str = $(this).val();
//replace search str in span value
$("#nav-search-in-content").text(Search_Str);
});

CSS Code

.search_bar {
width:965px;
height:auto;
float:left;
position:relative;
left:-17px;
}

#nav-search-label {
color: #333333;
display: block;
font-family: "Myriad Pro";
font-size: 14px;
font-weight: bold;
left: 140px;
line-height: 12px;
position: absolute;
top: 16px;
}
#nav-search-in {
display: inline-block;
height: 27px;
left: 202px;
overflow: hidden;
position: absolute;
top: 6px;
}
#nav-search-in #nav-search-in-content {
color: #777777;
display: inline-block;
font-family: "arial","sans-serif";
font-size: 11px;
height: 27px;
line-height: 27px;
margin: 0 59px 0 6px;
text-indent: 1px;
text-overflow: ellipsis;
white-space: nowrap;
}
#nav-search-in.nav-facade-active .nav-down-arrow {
display:inline-block;
right: 10px;
top: 11px;
background:url(search_arrow.png);
height:5px;
width:9px;
}
.nav-facade-active #searchDropdownBox {
cursor: pointer;
height: 29px;
left: 0;
opacity: 0;
top: 0;
visibility: visible;
width: auto;
}
#searchDropdownBox {
background: none repeat scroll 0 0 white;
border: 1px solid #DDDDDD;
color: black;
font-family: "arial","sans-serif";
left: 5px;
margin: 0;
outline: medium none;
padding: 0;
position: absolute;
top: 3px;
visibility: hidden;
width: 190px;
}
.nav-sprite {
background:url(search_bck.png) no-repeat;
}

.nav-searchfield-outer {
height: 30px;
margin-left: 190px;
margin-top: 5px;
width: 637px;
}

#twotabsearchtextbox {
background: none repeat scroll 0 0 transparent;
border: medium none;
box-shadow: none;
color: #333;
font-family: "Myriad Pro";
font-size: 14px;
height: 17px;
margin: 6px 165px 0;
outline: medium none;
padding: 0;
width: 72%;
font-weight:bold;
}
.nav-submit-button {
background-image: url(go_bttn.png);
height: 27px;
margin: 0;
overflow: hidden;
padding: 0 0 0 3px;
position: absolute;
right: 100px;
top: 7px;
}

.nav-submit-button .nav-submit-input {
background: none repeat scroll 0 0 transparent;
border: medium none;
color: white;
cursor: pointer;
font-size: 15px;
height: 28px;
font-family:"Myriad Pro";
line-height: 15px;
margin: 0;
padding: 0;
width: 34px;
}

Please don’t forget to share and subscribe to latest updates of the blog. Comments and feedbacks are always welcome!

Thanks!

View Live Demo & Download

You May Also Like

7 Responses

  1. Hi!
    how and where I have to insert Jquery code on the html page
    thank you

  2. Quoc Ho says:

    Hi.
    I need this.Thank you so much.

  3. skisy says:

    Can’t download source after several subscription attempts with different addresses on different days….

  4. kapil says:

    same here i cant download source

  5. kapil says:

    i get this type of error i
    subscribe many time plzzzzzzzzzzz helpppppppppppppppppppppppppppppppppppp

    or plzzzzzz mail me on my email id….

  6. IAMGROOT says:

    Using the same idea you posted here I didn’t think it functioned quite like the Amazon search bar so I used the code here as a starting point and rewrote it using floats. I didn’t like the select area to be fixed it should change width accordingly. Hope you like the improvements. https://jsfiddle.net/IAMGROOT/azqbLfd0/1/ since you cannot upload graphics i replaced the drop arrow and submit button with a solid color you just need to change the background to the image instead. Hope you like it. Now it works and looks exactly like the Amazon bar.

Leave a Reply

Your email address will not be published. Required fields are marked *