Search button inside the search box like Bing
Asked Answered
T

2

11

How can I implement a search button inside the search box, as seen on a site like Bing?

search box with graphic for button

Toandfro answered 27/8, 2010 at 6:22 Comment(0)
C
27

It just looks like it's inside but it's not (you cannot put html inside an input).

The 2 elements (an input and a button) are close together with 0 margin and both have the same height. The button's graphic has a 3px white margin. So it creates this effect.

A possible markup and styling could be:

<input type="text" id="q" />
<input type="button" id="b" value="Search" />


#q, #b { 
   margin: 0 
}
#q { 
   padding: 5px; 
   font-size: 2em; 
   line-height: 30px 
}
#b { 
   /* image replacement */
   text-indent: -99999px; 
   width: 30px; 
   height: 30px; 
   display: block;
   background: gray url(button.png) 0 0 no-repeat;

   /* placing next to input using float or absolute positioning omitted ... */
}
Cloison answered 27/8, 2010 at 6:24 Comment(1)
as an aside: you CAN put a button on top of a search bar by using relative or absolute positioning.Assiduity
P
3

A Cool Bing-like Search Box (Button on the Inside)

alt text

Paramagnetism answered 27/8, 2010 at 6:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.