Reputation: 3338
I have this control in the MVC view page as
@Html.TextBoxFor(m => m.TemplateGroupName,
new { tabindex = "1", placeholder = "Enter Template Group Name" })
Generated Control markup:-
<input class="input-validation-error" data-val="true"
data-val-required="The TemplateGroupName field is required."
id="TemplateGroupName" name="TemplateGroupName"
placeholder="Enter Template Group Name"
tabindex="1" value="" type="text">
I am trying to center-align the placeholder text. Please suggest.
Upvotes: 1
Views: 2159
Reputation: 79
For Aligning the content within the textbox in MVC we use 'Text-Align' Property.
@Html.TextBox("Name",new{placeholder="Your Text",style="Text-align:Center"});
Upvotes: 1
Reputation: 1326
Place following css on your page. It will center align placeholder in all browsers:
::-webkit-input-placeholder {
text-align: center;
}
:-moz-placeholder { /* Firefox 18- */
text-align: center;
}
::-moz-placeholder { /* Firefox 19+ */
text-align: center;
}
:-ms-input-placeholder {
text-align: center;
}
OR
you can implement the styling to a particular textbox like this:
@Html.TextBoxFor(m => m.TemplateGroupName,
new { tabindex = "1", placeholder = "Enter Template Group Name", Style = "text-align:center;" })
Upvotes: 4