如何在angularjs中使用图像占位符 [英] How to have an image placeholder in angularjs
本文介绍了如何在angularjs中使用图像占位符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个搜索输入框,当前未选择时显示Search here
,但是我可以用图像代替文字吗?
I have a search input box and currently when it is not selected it shows Search here
but instead of text can I have an image?
代码
<input id="autoComplete" type="text" ng-model="selected" typeahead="task.name for task in taskList | filter:$viewValue | limitTo:20" class="form-control" typeahead-on-select='onSelect($item, $model, $label)' placeholder="Search here" typeahead-focus-first="true" ng-disabled="loading" ng-blur="autocompleteBlurred()" />
这是您可以检查的朋克链接.
推荐答案
您可以直接使用CSS
You can do it directly using css
input#autoComplete {
background-image: url(https://cdn1.iconfinder.com/data/icons/hawcons/32/698627-icon-111-search-16.png);
background-position: 10px center;
background-repeat: no-repeat;
border: 1px solid #ccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-ms-border-radius: 4px;
-o-border-radius: 4px;
border-radius: 4px;
padding: 10px 5px;
text-indent: 20px;
-webkit-transition: all 0.2s;
-moz-transition: all 2s;
transition: all 0.2s;
}
input#autoComplete:focus {
background-position: -20px center;
text-indent: 0;
}
检查此朋克车
如果您还想输入文字,请不要从输入中删除placeholder="Search"
In case if you want text also do not remove placeholder="Search"
from your input
这篇关于如何在angularjs中使用图像占位符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文