Search button inside the search box like Bing

前端 未结 2 700
眼角桃花
眼角桃花 2020-12-09 20:13

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

\"search

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 20:40

    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:

    
    
    
    
    #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 ... */
    }
    

提交回复
热议问题