【发布时间】:2014-03-27 00:20:01
【问题描述】:
我正在创建一个搜索输入,并使用背景图像 css 作为搜索图标。
但是这会导致占位符和内容与左侧的背景图像重叠。
有没有办法让 div 中的文本从背景图像图标之后开始?如果您进行较长时间的搜索,然后取消聚焦输入,您将看到它重叠。
jsfiddle:
代码:
<form class="searchform" action="search.php?" method="get">
<input type="text" id="filtersearch" name="st" placeholder="search..." />
</form>
#filtersearch {
width: 100px;
padding-right: 5px;
border-radius: 0px;
border:none;
background-color: #555;
color:#fff;
font-size: 15px;
float:left;
text-align: center;
Display: table;
margin-left: 0%;
height: 100%;
margin-top: 0px;
-webkit-appearance: none;
background-image: url('http://buildsanctuary.com/images/icons/searchicon.png');
background-repeat: no-repeat;
}
#filtersearch:focus {
text-align: center;
width: 100%;
outline: none;
background-color: #555;
-webkit-transition: width 200ms;
-moz-transition: width 200ms;
-o-transition: width 200ms;
-ms-transition: width 200ms;
transition: width 0.25;
display: block;
}
.searchform {
width: 200px;
float:left;
height: 35px;
}
*注意,尚未确定最大字符长度。
【问题讨论】:
标签: html css forms search input