3

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?

enter image description here

code

<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()" />

Here is a plunker link you can check.

  • check this thread http://stackoverflow.com/questions/13761654/html5-image-icon-to-input-placeholder – kachhalimbu Jun 04 '15 at 06:29
  • you can also check this one: http://stackoverflow.com/questions/22655493/how-can-i-style-individual-parts-of-an-input-placeholder/22655903#22655903 – dfsq Jun 04 '15 at 06:31

1 Answers1

1

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

Check this plunker

In case if you want text also do not remove placeholder="Search" from your input

AabinGunz
  • 12,109
  • 54
  • 146
  • 218