我想在搜索框内实现一个搜索按钮,我发现它很有用:Search button inside the search box like Bing
但是当我将代码放入我的站点时,它没有按预期方式显示,这是怎么回事?
这是代码
HTML
<input type="text" id="q" />
<input type="button" id="b" value="Search" />
CSS
#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;
}
最佳答案
试试这个
#q, #b {
margin: 0
display:inline-block;
float:left;
}
#q {
padding 5px;
font-size: 2em;
line-height: 30px;
border:none;
}
#b {
/* image replacement */
margin-top:8px;
width: 30px;
height: 30px;
background: gray url(button.png) 0 0 no-repeat;
}
.border {
border:#ccc solid 1px;
width:390px;
}
.clear {
clear:both;
}
<div class="border">
<input type="text" id="q" />
<input type="button" id="b" value="Search" />
<div class="clear"></div>
</div>
关于html - 搜索框内的搜索按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18973353/