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; // Note: This has no effect on <select>s in some browsers, due to the limited stylability of <select>s in CSS.
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] & {
144 cursor: @cursor-disabled;
145 background-color: @input-bg-disabled;
146 opacity: 1; // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655
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. As a workaround, we
172 // set a pixel line-height that matches the given height of the input, but only
173 // for Safari. See https://bugs.webkit.org/show_bug.cgi?id=139848
175 @media screen and (-webkit-min-device-pixel-ratio: 0) {
178 input[type="datetime-local"],
179 input[type="month"] {
180 line-height: @input-height-base;
184 line-height: @input-height-small;
189 line-height: @input-height-large;
197 // Designed to help with the organization and spacing of vertical forms. For
198 // horizontal forms, use the predefined grid classes.
205 // Checkboxes and radios
207 // Indent the labels to position radios/checkboxes as hanging controls.
217 min-height: @line-height-computed; // Ensure the input doesn't jump when there is no text
224 .radio input[type="radio"],
225 .radio-inline input[type="radio"],
226 .checkbox input[type="checkbox"],
227 .checkbox-inline input[type="checkbox"] {
234 .checkbox + .checkbox {
235 margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing
238 // Radios and checkboxes on same line
241 display: inline-block;
244 vertical-align: middle;
248 .radio-inline + .radio-inline,
249 .checkbox-inline + .checkbox-inline {
251 margin-left: 10px; // space out consecutive inline controls
254 // Apply same disabled cursor tweak as for inputs
255 // Some special care is needed because <label>s don't inherit their parent's `cursor`.
257 // Note: Neither radios nor checkboxes can be readonly.
259 input[type="checkbox"] {
262 fieldset[disabled] & {
263 cursor: @cursor-disabled;
266 // These classes are used directly on <label>s
270 fieldset[disabled] & {
271 cursor: @cursor-disabled;
274 // These classes are used on elements with <label> descendants
278 fieldset[disabled] & {
280 cursor: @cursor-disabled;
286 // Static form control text
288 // Apply class to a `p` element to make any string of text align with labels in
289 // a horizontal form layout.
291 .form-control-static {
292 // Size it appropriately next to real form controls
293 padding-top: (@padding-base-vertical + 1);
294 padding-bottom: (@padding-base-vertical + 1);
295 // Remove default margin from `p`
306 // Form control sizing
308 // Build on `.form-control` with modifier classes to decrease or increase the
309 // height and font-size of form controls.
311 // The `.form-group-* form-control` variations are sadly duplicated to avoid the
312 // issue documented in https://github.com/twbs/bootstrap/issues/15074.
315 .input-size(@input-height-small; @padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @input-border-radius-small);
319 .input-size(@input-height-small; @padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @input-border-radius-small);
321 .form-control-static {
322 height: @input-height-small;
323 padding: @padding-small-vertical @padding-small-horizontal;
324 font-size: @font-size-small;
325 line-height: @line-height-small;
330 .input-size(@input-height-large; @padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @input-border-radius-large);
334 .input-size(@input-height-large; @padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @input-border-radius-large);
336 .form-control-static {
337 height: @input-height-large;
338 padding: @padding-large-vertical @padding-large-horizontal;
339 font-size: @font-size-large;
340 line-height: @line-height-large;
345 // Form control feedback states
347 // Apply contextual and semantic states to individual form controls.
350 // Enable absolute positioning
353 // Ensure icons don't overlap text
355 padding-right: (@input-height-base * 1.25);
358 // Feedback icon (requires .glyphicon classes)
359 .form-control-feedback {
363 z-index: 2; // Ensure icon is above input groups
365 width: @input-height-base;
366 height: @input-height-base;
367 line-height: @input-height-base;
369 pointer-events: none;
371 .input-lg + .form-control-feedback {
372 width: @input-height-large;
373 height: @input-height-large;
374 line-height: @input-height-large;
376 .input-sm + .form-control-feedback {
377 width: @input-height-small;
378 height: @input-height-small;
379 line-height: @input-height-small;
384 .form-control-validation(@state-success-text; @state-success-text; @state-success-bg);
387 .form-control-validation(@state-warning-text; @state-warning-text; @state-warning-bg);
390 .form-control-validation(@state-danger-text; @state-danger-text; @state-danger-bg);
393 // Reposition feedback icon if input has visible label above
394 .has-feedback label {
396 & ~ .form-control-feedback {
397 top: (@line-height-computed + 5); // Height of the `label` and its margin
399 &.sr-only ~ .form-control-feedback {
407 // Apply to any element you wish to create light text for placement immediately
408 // below a form control. Use for general help, formatting, or instructional text.
411 display: block; // account for any element using help-block
414 color: lighten(@text-color, 25%); // lighten the text some for contrast
420 // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
421 // forms begin stacked on extra small (mobile) devices and then go inline when
422 // viewports reach <768px.
424 // Requires wrapping inputs and labels with `.form-group` for proper display of
425 // default HTML form controls and our custom form controls (e.g., input groups).
427 // Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
431 // Kick in the inline
432 @media (min-width: @screen-sm-min) {
433 // Inline-block all the things for "inline"
435 display: inline-block;
437 vertical-align: middle;
440 // In navbar-form, allow folks to *not* use `.form-group`
442 display: inline-block;
443 width: auto; // Prevent labels from stacking above inputs in `.form-group`
444 vertical-align: middle;
447 // Make static controls behave like regular ones
448 .form-control-static {
449 display: inline-block;
453 display: inline-table;
454 vertical-align: middle;
463 // Input groups need that 100% width though
464 .input-group > .form-control {
470 vertical-align: middle;
473 // Remove default margin on radios/checkboxes that were used for stacking, and
474 // then undo the floating of radios and checkboxes to match.
477 display: inline-block;
480 vertical-align: middle;
486 .radio input[type="radio"],
487 .checkbox input[type="checkbox"] {
492 // Re-override the feedback icon.
493 .has-feedback .form-control-feedback {
502 // Horizontal forms are built on grid classes and allow you to create forms with
503 // labels on the left and inputs on the right.
507 // Consistent vertical alignment of radios and checkboxes
509 // Labels also get some reset styles, but that is scoped to a media query below.
516 padding-top: (@padding-base-vertical + 1); // Default padding plus a border
518 // Account for padding we're adding to ensure the alignment and of help text
519 // and other content below items
522 min-height: (@line-height-computed + (@padding-base-vertical + 1));
525 // Make form groups behave like rows
530 // Reset spacing and right align labels, but scope to media queries so that
531 // labels on narrow viewports stack the same as a default form example.
532 @media (min-width: @screen-sm-min) {
536 padding-top: (@padding-base-vertical + 1); // Default padding plus a border
542 // Reposition the icon because it's now within a grid column and columns have
543 // `position: relative;` on them. Also accounts for the grid gutter padding.
544 .has-feedback .form-control-feedback {
545 right: (@grid-gutter-width / 2);
550 // Quick utility class for applying `.input-lg` and `.input-sm` styles to the
551 // inputs and labels within a `.form-group`.
553 @media (min-width: @screen-sm-min) {
555 padding-top: ((@padding-large-vertical * @line-height-large) + 1);
560 @media (min-width: @screen-sm-min) {
562 padding-top: (@padding-small-vertical + 1);