I am having a normal asp.net text box with a background image with properties as shown below:
.userbackground
{
background-image: url('../images/user.png');
background-repeat: no-repeat;
background-position: fixed;
text-align:center;
width:16px;
height:16px;
}
This is the view of my textbox:

And here is my textbox:
<asp:TextBox ID="UserName" runat="server" BorderStyle="Solid" BorderWidth="1px"
BorderColor="#0099CC" BackColor="#FAFFBD" MaxLength="0"
AutoCompleteType="Disabled" CssClass="userbackground"></asp:TextBox>
Now I would like to know is there any possiblity to set the margin for the inside text or place the cursor position after that image and if user clears the text inside the cursor should stop before the image.
I have tried using css properties: text align:middle but it starts from the center and I don’t want that and making a background image also dosen’t suits my needs.showing and hiding image also is not a good option in my case as I have many.Other than these three options anyone can opt me the best way I am really glad to hear them.
You could put the textbox in a
divwith abackground-image, and position the textbox with padding so that it doesn’t overlap the image:— SEE DEMO —