1

I am struggling to change the font size for MVC TextBoxFor?

I can change the font size when using:

input, textarea {}

But this changes all my input size's. I also tried to then add a css class to my TextboxFor:

@Html.EditorFor(model => model.UserName, new { @Class = "Mytextarea" })

css

.Mytextarea {
    font-size: 0.85em !important;
    height: 14px !important;
    color: #333 !important;
    /*font-family: inherit;*/
    width: 300px;

}

This has had no affect.

My TextBoxFor's are huge and bulky and i have no way to change them, If possible i would like to set styling to change them all at once.


Edit:

enter image description here

enter image description here

12
  • Did you see the chrome/firefox debugging tool(press f12) html element section and checked what css class was applied? Commented Jun 5, 2014 at 16:15
  • @Murali Yes it says "Text-box single-line" i have no idea where that style is from. That's the class its given, they styling looks like its taking input, dropdown. .... But its a text box :\ Commented Jun 5, 2014 at 16:16
  • Can you add the snapshot with chrome console? It should be from some css file only Commented Jun 5, 2014 at 16:18
  • Are you using any other form plugin? Are you sure the correct view you are looking into it?. I dont see any problem in MVC EditorFor. may be try with small letters @class="yourclass" Commented Jun 5, 2014 at 16:24
  • I don't even see .Mytextarea in the debugging window. Is that css rule in your site.css? Commented Jun 5, 2014 at 16:25

1 Answer 1

2

So, you start your question off asking about TextBoxFor, but your actual code references EditorFor.

When using the EditorFor extension, you need to write a custom editor template to describe the visual components. If you don't, it will use the default template, which is where "text-box single-line" is coming from.

See this answer for a quick explanation on how to build a template that you can assign to the EditorFor helper. Or just use TextBoxFor like this.

@Html.TextBoxFor(model => model.UserName, new { @Class = "Mytextarea" })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.