In my jQuery mobile app , I need to position the search Icon and Place holder of a search input field at the center , I have tried the folowing code but it didnt work , the placeholder and the icon are still appearing at the left on android devices . Please help me How can I Position the SearchIcon and Placeholder at the center of the Search input field ?
<input type="search" id="SearchFilter" placeholder="Search.." />
<ul data-role="listview" data-filter="true" data-input="#SearchFilter"
data-split-icon="delete">
// All Elements
</ul>
CSS
::-webkit-input-placeholder { // its working on jsfiddle but it didnt work on mobile devices
color: grey;
text-align:center;
}
#SearchFilter{
text-shadow:none;
text-align:center;
}
.ui-icon-SearchIcon:after{
background-image: url(icons/searchIcon.png);
background-size: 100% 100%;
background-position: 0 50%;
width:32px;
height:32px;
text-align:center;
float:center;
}
To expand on ezanker's answer, you can also remove the search icon as there is a class applied once the input gains focus, therefore you could rewrite the css to look like (I also styled the icon position more to my liking):
Demo
Putting placeholder text in the middle:
Do you want tyled text in the middle too?
If Yes:
If No:
You can place the icon in the center if you like, however it does not disappear when you type, so I think it does not make sense. But if you like: