如何在搜索框内实现搜索按钮,就像在 Bing 等网站上看到的那样?
最佳答案
它看起来像是在里面,但实际上不是(你不能将 html 放在输入中)。
两个元素(一个输入和一个按钮)靠得很近,边距为 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 ... */
}
关于css - Bing 等搜索框内的搜索按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25381658/