搜索框内的搜索按钮就像Bing一样

时间:2010-08-27 06:22:29

标签: css bing search-box

如何在搜索框中实现搜索按钮,如Bing等网站上所示?

search box with graphic for button

2 个答案:

答案 0 :(得分:23)

它看起来像是在里面但它不是(你不能把html放在输入中)。

2个元素(输入和按钮)靠近在一起,边距为0,两者都有相同的高度。按钮的图形具有3px白色边距。所以它会产生这种效果。

可能的标记和样式可能是:

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

答案 1 :(得分:3)

相关问题