3 // --------------------------------------------------
6 // Normalize non-controls
8 // Restyle and baseline non-control form elements.
14 // Chrome and Firefox set a `min-width: 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;
34 max-width: 100%; // Force IE8 to wrap long content (see https://github.com/twbs/bootstrap/issues/13141)
40 // Normalize form controls
42 // While most of our form styles require extra classes, some basic normalization
43 // is required to ensure optimum display with or without those classes to better
44 // address browser inconsistencies.
46 // Override content-box in Normalize (* isn't specific enough)
47 input[type="search"] {
48 .box-sizing(border-box);
51 // Position radios and checkboxes better
53 input[type="checkbox"] {
55 margin-top: 1px \9; // IE8-9
59 // Set the height of file controls to match text inputs
64 // Make range inputs behave like textual form controls
70 // Make multiple select elements height not fixed
76 // Focus for file, radio, and checkbox
77 input[type="file"]:focus,
78 input[type="radio"]:focus,
79 input[type="checkbox"]:focus {
83 // Adjust output element
86 padding-top: (@padding-base-vertical + 1);
87 font-size: @font-size-base;
88 line-height: @line-height-base;
93 // Common form controls
95 // Shared size and type resets for form controls. Apply `.form-control` to any
96 // of the following form controls:
100 // input[type="text"]
101 // input[type="password"]
102 // input[type="datetime"]
103 // input[type="datetime-local"]
104 // input[type="date"]
105 // input[type="month"]
106 // input[type="time"]
107 // input[type="week"]
108 // input[type="number"]
109 // input[type="email"]
111 // input[type="search"]
113 // input[type="color"]
118 height: @input-height-base; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
119 padding: @padding-base-vertical @padding-base-horizontal;
120 font-size: @font-size-base;
121 line-height: @line-height-base;
123 background-color: @input-bg;
124 background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
125 border: 1px solid @input-border;
126 border-radius: @input-border-radius;
127 .box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
128 .transition(~"border-color ease-in-out .15s, box-shadow ease-in-out .15s");
130 // Customize the `:focus` state to imitate native WebKit styles.
131 .form-control-focus();
136 // Disabled and read-only inputs
138 // HTML5 says that controls under a fieldset > legend:first-child won't be
139 // disabled if the fieldset is disabled. Due to implementation difficulty, we
140 // don't honor that edge case; we style them as disabled anyway.
143 fieldset[disabled] & {
145 background-color: @input-bg-disabled;
146 opacity: 1; // iOS fix for unreadable disabled content
149 // Reset height for `textarea`s
156 // Search inputs in iOS
158 // This overrides the extra rounded corners on search inputs in iOS so that our
159 // `.form-control` class can properly style them. Note that this cannot simply
160 // be added to `.form-control` as it's not specific enough. For details, see
161 // https://github.com/twbs/bootstrap/issues/11586.
163 input[type="search"] {
164 -webkit-appearance: none;
168 // Special styles for iOS temporal inputs
170 // In Mobile Safari, setting `display: block` on temporal inputs causes the
171 // text within the input to become vertically misaligned.
172 // As a workaround, we set a pixel line-height that matches the
173 // given height of the input. Since this fucks up everything else, we have to
174 // appropriately reset it for Internet Explorer and the size variations.
178 input[type="datetime-local"],
179 input[type="month"] {
180 line-height: @input-height-base;
181 // IE8+ misaligns the text within date inputs, so we reset
182 line-height: @line-height-base ~"\0";
185 line-height: @input-height-small;
188 line-height: @input-height-large;
195 // Designed to help with the organization and spacing of vertical forms. For
196 // horizontal forms, use the predefined grid classes.
203 // Checkboxes and radios
205 // Indent the labels to position radios/checkboxes as hanging controls.
211 min-height: @line-height-computed; // clear the floating input if there is no label text
222 .radio input[type="radio"],
223 .radio-inline input[type="radio"],
224 .checkbox input[type="checkbox"],
225 .checkbox-inline input[type="checkbox"] {
232 .checkbox + .checkbox {
233 margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing
236 // Radios and checkboxes on same line
239 display: inline-block;
242 vertical-align: middle;
246 .radio-inline + .radio-inline,
247 .checkbox-inline + .checkbox-inline {
249 margin-left: 10px; // space out consecutive inline controls
252 // Apply same disabled cursor tweak as for inputs
253 // Some special care is needed because <label>s don't inherit their parent's `cursor`.
255 // Note: Neither radios nor checkboxes can be readonly.
257 input[type="checkbox"] {
260 fieldset[disabled] & {
264 // These classes are used directly on <label>s
268 fieldset[disabled] & {
272 // These classes are used on elements with <label> descendants
276 fieldset[disabled] & {
284 // Static form control text
286 // Apply class to a `p` element to make any string of text align with labels in
287 // a horizontal form layout.
289 .form-control-static {
290 // Size it appropriately next to real form controls
291 padding-top: (@padding-base-vertical + 1);
292 padding-bottom: (@padding-base-vertical + 1);
293 // Remove default margin from `p`
304 // Form control sizing
306 // Build on `.form-control` with modifier classes to decrease or increase the
307 // height and font-size of form controls.
310 .input-size(@input-height-small; @padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @border-radius-small);
314 .input-size(@input-height-large; @padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @border-radius-large);
318 // Form control feedback states
320 // Apply contextual and semantic states to individual form controls.
323 // Enable absolute positioning
326 // Ensure icons don't overlap text
328 padding-right: (@input-height-base * 1.25);
331 // Feedback icon (requires .glyphicon classes)
332 .form-control-feedback {
334 top: (@line-height-computed + 5); // Height of the `label` and its margin
336 z-index: 2; // Ensure icon is above input groups
338 width: @input-height-base;
339 height: @input-height-base;
340 line-height: @input-height-base;
343 .input-lg + .form-control-feedback {
344 width: @input-height-large;
345 height: @input-height-large;
346 line-height: @input-height-large;
348 .input-sm + .form-control-feedback {
349 width: @input-height-small;
350 height: @input-height-small;
351 line-height: @input-height-small;
356 .form-control-validation(@state-success-text; @state-success-text; @state-success-bg);
359 .form-control-validation(@state-warning-text; @state-warning-text; @state-warning-bg);
362 .form-control-validation(@state-danger-text; @state-danger-text; @state-danger-bg);
366 // Reposition feedback icon if label is hidden with "screenreader only" state
367 .has-feedback label.sr-only ~ .form-control-feedback {
374 // Apply to any element you wish to create light text for placement immediately
375 // below a form control. Use for general help, formatting, or instructional text.
378 display: block; // account for any element using help-block
381 color: lighten(@text-color, 25%); // lighten the text some for contrast
388 // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
389 // forms begin stacked on extra small (mobile) devices and then go inline when
390 // viewports reach <768px.
392 // Requires wrapping inputs and labels with `.form-group` for proper display of
393 // default HTML form controls and our custom form controls (e.g., input groups).
395 // Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
399 // Kick in the inline
400 @media (min-width: @screen-sm-min) {
401 // Inline-block all the things for "inline"
403 display: inline-block;
405 vertical-align: middle;
408 // In navbar-form, allow folks to *not* use `.form-group`
410 display: inline-block;
411 width: auto; // Prevent labels from stacking above inputs in `.form-group`
412 vertical-align: middle;
416 display: inline-table;
417 vertical-align: middle;
426 // Input groups need that 100% width though
427 .input-group > .form-control {
433 vertical-align: middle;
436 // Remove default margin on radios/checkboxes that were used for stacking, and
437 // then undo the floating of radios and checkboxes to match (which also avoids
438 // a bug in WebKit: https://github.com/twbs/bootstrap/issues/1969).
441 display: inline-block;
444 vertical-align: middle;
450 .radio input[type="radio"],
451 .checkbox input[type="checkbox"] {
458 // Reposition the icon because it's now within a grid column and columns have
459 // `position: relative;` on them. Also accounts for the grid gutter padding.
460 .has-feedback .form-control-feedback {
469 // Horizontal forms are built on grid classes and allow you to create forms with
470 // labels on the left and inputs on the right.
474 // Consistent vertical alignment of radios and checkboxes
476 // Labels also get some reset styles, but that is scoped to a media query below.
483 padding-top: (@padding-base-vertical + 1); // Default padding plus a border
485 // Account for padding we're adding to ensure the alignment and of help text
486 // and other content below items
489 min-height: (@line-height-computed + (@padding-base-vertical + 1));
492 // Make form groups behave like rows
497 // Reset spacing and right align labels, but scope to media queries so that
498 // labels on narrow viewports stack the same as a default form example.
499 @media (min-width: @screen-sm-min) {
503 padding-top: (@padding-base-vertical + 1); // Default padding plus a border
509 // Reposition the icon because it's now within a grid column and columns have
510 // `position: relative;` on them. Also accounts for the grid gutter padding.
511 .has-feedback .form-control-feedback {
513 right: (@grid-gutter-width / 2);
518 // Quick utility class for applying `.input-lg` and `.input-sm` styles to the
519 // inputs and labels within a `.form-group`.
521 @media (min-width: @screen-sm-min) {
523 padding-top: ((@padding-large-vertical * @line-height-large) + 1);
531 @media (min-width: @screen-sm-min) {
533 padding-top: (@padding-small-vertical + 1);