BS Forms
Bootstrap's Default Settings
Bootstrap automatically styles form controls globally:
All textual <input>, <textarea>, and <select> elements with class .form-control have a 100% width.
Bootstrap Form Layouts
Bootstrap offers three different form layouts:
- Vertical form (the default)
- The horizontal form
- Linear form
Standard rules for each of the three form layouts:
- Wrap labels and form controls in this <div class=”form-group”>. (Required for optimal spacing)
- Add the .form-control class to all <input>, <textarea>, and <select> elements.
Bootstrap Vertical Form (default)
------list mukava -----
The example below generates a vertical form with two input fields, one checkbox, and a submit button.
Example
Bootstrap Inline Form
------list mukava -----
In an inline form, all elements are inline and left-aligned, with labels alongside.
This only applies to forms within viewports that are at least 768 pixels wide!
Additional rule for an online form:
- Add class .form-inline to the <form> element.
The example below generates an inline form with two input fields, one checkbox, and one submit button.
Example
Tip: If you don’t name each input, screen readers will struggle with your forms. You can conceal the labels for all devices, except screen readers, by using the.sr-only class:
Example
Bootstrap Horizontal Form
------list mukava -----
A horizontal form indicates that the labels are situated next to the input field (horizontal) on big and medium screens. On narrow screens (767px and less), it will take on a vertical form (labels are placed on top of each input).
Additional rules for horizontal forms:
- Add class .form-horizontal to the <form> element.
- Add the class .control-label to all <label> elements.
Tip: To align labels and form control groups in a horizontal layout, use Bootstrap’s default grid classes.
The example below generates a horizontal form with two input fields, one checkbox, and a submit button.
Example