Bootstrap: HTML input checkbox with class .form-control width problem

Created on 21 Mar 2015  路  4Comments  路  Source: twbs/bootstrap

Hi,

When generating a checkbox field with MVC Razor, as follows:

@Html.EditorFor(model => model.IsHappy)

It inserts the class form-control to the generated input element, which is in this case a checkbox.
What happens is, the element becomes huge to take up free space:

I found it that what's causing this issue is the width=100% setting of .form-control, and when I add the following underneath the .form-control classes in the _bootstrap.css_ file, issue is solved.

css

Most helpful comment

.form-control is only meant for use on <textarea>s, <select>s, and textual <input>s.
Use the .checkbox class for checkboxes (see the docs for details on usage).

All 4 comments

.form-control is only meant for use on <textarea>s, <select>s, and textual <input>s.
Use the .checkbox class for checkboxes (see the docs for details on usage).

I guess this is something the ASP.NET MVC Razor engine team missed out.

Thanks and sorry for bothering!

I did not understand what is the solution and how to implement it. Please, explain like I have 6yo because I am not a CSS expert. Thanks.

The solution was to just to not use .form-control class for checkboxes

Was this page helpful?
0 / 5 - 0 ratings

Related issues

XhmikosR picture XhmikosR  路  43Comments

juampi picture juampi  路  49Comments

dharmeshpipariya-zz picture dharmeshpipariya-zz  路  38Comments

tobi-or-not-tobi picture tobi-or-not-tobi  路  75Comments

mdo picture mdo  路  66Comments