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/
Image may be NSFW.
Clik here to view.
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!