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

vik*_*tra 9 css search-box bing

如何在Bing这样的网站上看到搜索框内的搜索按钮?

搜索框与图形按钮

che*_*vim 24

它只是看起来像在里面,但它不是(你不能把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 ... */
}
Run Code Online (Sandbox Code Playgroud)