3 // --------------------------------------------------
6 // Normalize non-controls
8 // Restyle and baseline non-control form elements.
14 // Chrome and Firefox set a `min-width: -webkit-min-content;` on fieldsets,
15 // so we reset that to ensure it behaves more like a standard block element.
16 // See https://github.com/twbs/bootstrap/issues/12359.
24 margin-bottom: @line-height-computed;
25 font-size: (@font-size-base * 1.5);
29 border-bottom: 1px solid @legend-border-color;
33 display: inline-block;
39 // Normalize form controls
41 // While most of our form styles require extra classes, some basic normalization
42 // is required to ensure optimum display with or without those classes to better
43 // address browser inconsistencies.
45 // Override content-box in Normalize (* isn't specific enough)
46 input[type="search"] {
47 .box-sizing(border-box);
50 // Position radios and checkboxes better
52 input[type="checkbox"] {
54 margin-top: 1px \9; /* IE8-9 */
58 // Set the height of file controls to match text inputs
63 // Make range inputs behave like textual form controls
69 // Make multiple select elements height not fixed
75 // Focus for file, radio, and checkbox
76 input[type="file"]:focus,
77 input[type="radio"]:focus,
78 input[type="checkbox"]:focus {
82 // Adjust output element
85 padding-top: (@padding-base-vertical + 1);
86 font-size: @font-size-base;
87 line-height: @line-height-base;
92 // Common form controls
94 // Shared size and type resets for form controls. Apply `.form-control` to any
95 // of the following form controls:
100 // input[type="password"]
101 // input[type="datetime"]
102 // input[type="datetime-local"]
103 // input[type="date"]
104 // input[type="month"]
105 // input[type="time"]
106 // input[type="week"]
107 // input[type="number"]
108 // input[type="email"]
110 // input[type="search"]
112 // input[type="color"]
117 height: @input-height-base; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
118 padding: @padding-base-vertical @padding-base-horizontal;
119 font-size: @font-size-base;
120 line-height: @line-height-base;
122 background-color: @input-bg;
123 background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
124 border: 1px solid @input-border;
125 border-radius: @input-border-radius;
126 .box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
127 .transition(~"border-color ease-in-out .15s, box-shadow ease-in-out .15s");
129 // Customize the `:focus` state to imitate native WebKit styles.
130 .form-control-focus();
135 // Disabled and read-only inputs
137 // HTML5 says that controls under a fieldset > legend:first-child won't be
138 // disabled if the fieldset is disabled. Due to implementation difficulty, we
139 // don't honor that edge case; we style them as disabled anyway.
142 fieldset[disabled] & {
144 background-color: @input-bg-disabled;
145 opacity: 1; // iOS fix for unreadable disabled content
148 // Reset height for `textarea`s
155 // Search inputs in iOS
157 // This overrides the extra rounded corners on search inputs in iOS so that our
158 // `.form-control` class can properly style them. Note that this cannot simply
159 // be added to `.form-control` as it's not specific enough. For details, see
160 // https://github.com/twbs/bootstrap/issues/11586.
162 input[type="search"] {
163 -webkit-appearance: none;
167 // Special styles for iOS date input
169 // In Mobile Safari, date inputs require a pixel line-height that matches the
170 // given height of the input.
173 line-height: @input-height-base;
179 // Designed to help with the organization and spacing of vertical forms. For
180 // horizontal forms, use the predefined grid classes.
187 // Checkboxes and radios
189 // Indent the labels to position radios/checkboxes as hanging controls.
194 min-height: @line-height-computed; // clear the floating input if there is no label text
204 .radio input[type="radio"],
205 .radio-inline input[type="radio"],
206 .checkbox input[type="checkbox"],
207 .checkbox-inline input[type="checkbox"] {
212 .checkbox + .checkbox {
213 margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing
216 // Radios and checkboxes on same line
219 display: inline-block;
222 vertical-align: middle;
226 .radio-inline + .radio-inline,
227 .checkbox-inline + .checkbox-inline {
229 margin-left: 10px; // space out consecutive inline controls
232 // Apply same disabled cursor tweak as for inputs
234 // Note: Neither radios nor checkboxes can be readonly.
236 input[type="checkbox"],
242 fieldset[disabled] & {
248 // Form control sizing
250 // Build on `.form-control` with modifier classes to decrease or increase the
251 // height and font-size of form controls.
254 .input-size(@input-height-small; @padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @border-radius-small);
258 .input-size(@input-height-large; @padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @border-radius-large);
262 // Form control feedback states
264 // Apply contextual and semantic states to individual form controls.
267 // Enable absolute positioning
270 // Ensure icons don't overlap text
272 padding-right: (@input-height-base * 1.25);
275 // Feedback icon (requires .glyphicon classes)
276 .form-control-feedback {
278 top: (@line-height-computed + 5); // Height of the `label` and its margin
281 width: @input-height-base;
282 height: @input-height-base;
283 line-height: @input-height-base;
290 .form-control-validation(@state-success-text; @state-success-text; @state-success-bg);
293 .form-control-validation(@state-warning-text; @state-warning-text; @state-warning-bg);
296 .form-control-validation(@state-danger-text; @state-danger-text; @state-danger-bg);
300 // Static form control text
302 // Apply class to a `p` element to make any string of text align with labels in
303 // a horizontal form layout.
305 .form-control-static {
306 margin-bottom: 0; // Remove default margin from `p`
312 // Apply to any element you wish to create light text for placement immediately
313 // below a form control. Use for general help, formatting, or instructional text.
316 display: block; // account for any element using help-block
319 color: lighten(@text-color, 25%); // lighten the text some for contrast
326 // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
327 // forms begin stacked on extra small (mobile) devices and then go inline when
328 // viewports reach <768px.
330 // Requires wrapping inputs and labels with `.form-group` for proper display of
331 // default HTML form controls and our custom form controls (e.g., input groups).
333 // Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
337 // Kick in the inline
338 @media (min-width: @screen-sm-min) {
339 // Inline-block all the things for "inline"
341 display: inline-block;
343 vertical-align: middle;
346 // In navbar-form, allow folks to *not* use `.form-group`
348 display: inline-block;
349 width: auto; // Prevent labels from stacking above inputs in `.form-group`
350 vertical-align: middle;
352 // Input groups need that 100% width though
353 .input-group > .form-control {
359 vertical-align: middle;
362 // Remove default margin on radios/checkboxes that were used for stacking, and
363 // then undo the floating of radios and checkboxes to match (which also avoids
364 // a bug in WebKit: https://github.com/twbs/bootstrap/issues/1969).
367 display: inline-block;
371 vertical-align: middle;
373 .radio input[type="radio"],
374 .checkbox input[type="checkbox"] {
381 // Reposition the icon because it's now within a grid column and columns have
382 // `position: relative;` on them. Also accounts for the grid gutter padding.
383 .has-feedback .form-control-feedback {
392 // Horizontal forms are built on grid classes and allow you to create forms with
393 // labels on the left and inputs on the right.
397 // Consistent vertical alignment of labels, radios, and checkboxes
405 padding-top: (@padding-base-vertical + 1); // Default padding plus a border
407 // Account for padding we're adding to ensure the alignment and of help text
408 // and other content below items
411 min-height: (@line-height-computed + (@padding-base-vertical + 1));
414 // Make form groups behave like rows
419 .form-control-static {
420 padding-top: (@padding-base-vertical + 1);
423 // Only right align form labels here when the columns stop stacking
424 @media (min-width: @screen-sm-min) {
432 // Reposition the icon because it's now within a grid column and columns have
433 // `position: relative;` on them. Also accounts for the grid gutter padding.
434 .has-feedback .form-control-feedback {
436 right: (@grid-gutter-width / 2);