gpt4 book ai didi

html - 从用作图标的重叠背景图像中停止占位符/输入文本?

转载 作者:太空宇宙 更新时间:2023-11-04 03:56:52 25 4
gpt4 key购买 nike

我正在创建搜索输入并使用背景图像 css 作为搜索图标。

然而,这会导致占位符和内容与左侧的背景图像重叠。

有没有办法让 div 中的文本从背景图像图标之后开始?如果您进行较长的搜索,然后取消输入的焦点,您会看到它重叠。

jsfiddle:

http://jsfiddle.net/ET4e7/

代码:

<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;
}

*请注意,尚未决定最大字符长度。

最佳答案

你只需要添加 padding-left: 20px; 到输入(或者不管图标实际有多大):

#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://placehold.it/20x37');
background-repeat: no-repeat;
padding-left: 20px; /* <-------------------------------------------------------- */
}

fiddle : Fiddle

关于html - 从用作图标的重叠背景图像中停止占位符/输入文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22675824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com