3 // --------------------------------------------------
5 // Normalize non-controls
7 // Restyle and baseline non-control form elements.
13 // Chrome and Firefox set a `min-width: min-content;` on fieldsets,
14 // so we reset that to ensure it behaves more like a standard block element.
15 // See https://github.com/twbs/bootstrap/issues/12359.
23 margin-bottom: $line-height-computed;
24 font-size: ($font-size-base * 1.5);
28 border-bottom: 1px solid $legend-border-color;
32 display: inline-block;
33 max-width: 100%; // Force IE8 to wrap long content (see https://github.com/twbs/bootstrap/issues/13141)
38 // Normalize form controls
40 // While most of our form styles require extra classes, some basic normalization
41 // is required to ensure optimum display with or without those classes to better
42 // address browser inconsistencies.
44 // Override content-box in Normalize (* isn't specific enough)
45 input[type="search"] {
46 @include box-sizing(border-box);
49 // Position radios and checkboxes better
51 input[type="checkbox"] {
53 margin-top: 1px \9; // IE8-9
61 // Make range inputs behave like textual form controls
67 // Make multiple select elements height not fixed
73 // Focus for file, radio, and checkbox
74 input[type="file"]:focus,
75 input[type="radio"]:focus,
76 input[type="checkbox"]:focus {
80 // Adjust output element
83 padding-top: ($padding-base-vertical + 1);
84 font-size: $font-size-base;
85 line-height: $line-height-base;
89 // Common form controls
91 // Shared size and type resets for form controls. Apply `.form-control` to any
92 // of the following form controls:
97 // input[type="password"]
98 // input[type="datetime"]
99 // input[type="datetime-local"]
100 // input[type="date"]
101 // input[type="month"]
102 // input[type="time"]
103 // input[type="week"]
104 // input[type="number"]
105 // input[type="email"]
107 // input[type="search"]
109 // input[type="color"]
114 height: $input-height-base; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
115 padding: $padding-base-vertical $padding-base-horizontal;
116 font-size: $font-size-base;
117 line-height: $line-height-base;
119 background-color: $input-bg;
120 background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
121 border: 1px solid $input-border;
122 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.
123 @include box-shadow(inset 0 1px 1px rgba(0, 0, 0, .075));
124 @include transition(border-color ease-in-out .15s, box-shadow ease-in-out .15s);
126 // Customize the `:focus` state to imitate native WebKit styles.
127 @include form-control-focus;
130 @include placeholder;
132 // Disabled and read-only inputs
134 // HTML5 says that controls under a fieldset > legend:first-child won't be
135 // disabled if the fieldset is disabled. Due to implementation difficulty, we
136 // don't honor that edge case; we style them as disabled anyway.
139 fieldset[disabled] & {
140 background-color: $input-bg-disabled;
141 opacity: 1; // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655
145 fieldset[disabled] & {
146 cursor: $cursor-disabled;
149 // [converter] extracted textarea& to textarea.form-control
152 // Reset height for `textarea`s
153 textarea.form-control {
157 // Search inputs in iOS
159 // This overrides the extra rounded corners on search inputs in iOS so that our
160 // `.form-control` class can properly style them. Note that this cannot simply
161 // be added to `.form-control` as it's not specific enough. For details, see
162 // https://github.com/twbs/bootstrap/issues/11586.
164 input[type="search"] {
165 -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 // Note that as of 8.3, iOS doesn't support `datetime` or `week`.
177 @media screen and (-webkit-min-device-pixel-ratio: 0) {
180 input[type="datetime-local"],
181 input[type="month"] {
183 line-height: $input-height-base;
188 line-height: $input-height-small;
193 line-height: $input-height-large;
200 // Designed to help with the organization and spacing of vertical forms. For
201 // horizontal forms, use the predefined grid classes.
204 margin-bottom: $form-group-margin-bottom;
207 // Checkboxes and radios
209 // Indent the labels to position radios/checkboxes as hanging controls.
219 min-height: $line-height-computed; // Ensure the input doesn't jump when there is no text
227 .radio input[type="radio"],
228 .radio-inline input[type="radio"],
229 .checkbox input[type="checkbox"],
230 .checkbox-inline input[type="checkbox"] {
237 .checkbox + .checkbox {
238 margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing
241 // Radios and checkboxes on same line
245 display: inline-block;
248 vertical-align: middle;
253 .radio-inline + .radio-inline,
254 .checkbox-inline + .checkbox-inline {
256 margin-left: 10px; // space out consecutive inline controls
259 // Apply same disabled cursor tweak as for inputs
260 // Some special care is needed because <label>s don't inherit their parent's `cursor`.
262 // Note: Neither radios nor checkboxes can be readonly.
264 input[type="checkbox"] {
267 fieldset[disabled] & {
268 cursor: $cursor-disabled;
272 // These classes are used directly on <label>s
276 fieldset[disabled] & {
277 cursor: $cursor-disabled;
281 // These classes are used on elements with <label> descendants
285 fieldset[disabled] & {
287 cursor: $cursor-disabled;
292 // Static form control text
294 // Apply class to a `p` element to make any string of text align with labels in
295 // a horizontal form layout.
297 .form-control-static {
298 // Size it appropriately next to real form controls
299 padding-top: ($padding-base-vertical + 1);
300 padding-bottom: ($padding-base-vertical + 1);
301 // Remove default margin from `p`
303 min-height: ($line-height-computed + $font-size-base);
312 // Form control sizing
314 // Build on `.form-control` with modifier classes to decrease or increase the
315 // height and font-size of form controls.
317 // The `.form-group-* form-control` variations are sadly duplicated to avoid the
318 // issue documented in https://github.com/twbs/bootstrap/issues/15074.
320 @include input-size('.input-sm', $input-height-small, $padding-small-vertical, $padding-small-horizontal, $font-size-small, $line-height-small, $input-border-radius-small);
323 height: $input-height-small;
324 padding: $padding-small-vertical $padding-small-horizontal;
325 font-size: $font-size-small;
326 line-height: $line-height-small;
327 border-radius: $input-border-radius-small;
329 select.form-control {
330 height: $input-height-small;
331 line-height: $input-height-small;
333 textarea.form-control,
334 select[multiple].form-control {
337 .form-control-static {
338 height: $input-height-small;
339 min-height: ($line-height-computed + $font-size-small);
340 padding: ($padding-small-vertical + 1) $padding-small-horizontal;
341 font-size: $font-size-small;
342 line-height: $line-height-small;
346 @include input-size('.input-lg', $input-height-large, $padding-large-vertical, $padding-large-horizontal, $font-size-large, $line-height-large, $input-border-radius-large);
349 height: $input-height-large;
350 padding: $padding-large-vertical $padding-large-horizontal;
351 font-size: $font-size-large;
352 line-height: $line-height-large;
353 border-radius: $input-border-radius-large;
355 select.form-control {
356 height: $input-height-large;
357 line-height: $input-height-large;
359 textarea.form-control,
360 select[multiple].form-control {
363 .form-control-static {
364 height: $input-height-large;
365 min-height: ($line-height-computed + $font-size-large);
366 padding: ($padding-large-vertical + 1) $padding-large-horizontal;
367 font-size: $font-size-large;
368 line-height: $line-height-large;
372 // Form control feedback states
374 // Apply contextual and semantic states to individual form controls.
377 // Enable absolute positioning
380 // Ensure icons don't overlap text
382 padding-right: ($input-height-base * 1.25);
386 // Feedback icon (requires .glyphicon classes)
387 .form-control-feedback {
391 z-index: 2; // Ensure icon is above input groups
393 width: $input-height-base;
394 height: $input-height-base;
395 line-height: $input-height-base;
397 pointer-events: none;
400 .input-lg + .form-control-feedback,
401 .input-group-lg + .form-control-feedback,
402 .form-group-lg .form-control + .form-control-feedback {
403 width: $input-height-large;
404 height: $input-height-large;
405 line-height: $input-height-large;
408 .input-sm + .form-control-feedback,
409 .input-group-sm + .form-control-feedback,
410 .form-group-sm .form-control + .form-control-feedback {
411 width: $input-height-small;
412 height: $input-height-small;
413 line-height: $input-height-small;
418 @include form-control-validation($state-success-text, $state-success-text, $state-success-bg);
422 @include form-control-validation($state-warning-text, $state-warning-text, $state-warning-bg);
426 @include form-control-validation($state-danger-text, $state-danger-text, $state-danger-bg);
429 // Reposition feedback icon if input has visible label above
430 .has-feedback label {
432 & ~ .form-control-feedback {
433 top: ($line-height-computed + 5); // Height of the `label` and its margin
435 &.sr-only ~ .form-control-feedback {
442 // Apply to any element you wish to create light text for placement immediately
443 // below a form control. Use for general help, formatting, or instructional text.
446 display: block; // account for any element using help-block
449 color: lighten($text-color, 25%); // lighten the text some for contrast
454 // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
455 // forms begin stacked on extra small (mobile) devices and then go inline when
456 // viewports reach <768px.
458 // Requires wrapping inputs and labels with `.form-group` for proper display of
459 // default HTML form controls and our custom form controls (e.g., input groups).
461 // Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
463 // [converter] extracted from `.form-inline` for libsass compatibility
466 // Kick in the inline
467 @media (min-width: $screen-sm-min) {
468 // Inline-block all the things for "inline"
470 display: inline-block;
472 vertical-align: middle;
475 // In navbar-form, allow folks to *not* use `.form-group`
477 display: inline-block;
478 width: auto; // Prevent labels from stacking above inputs in `.form-group`
479 vertical-align: middle;
482 // Make static controls behave like regular ones
483 .form-control-static {
484 display: inline-block;
488 display: inline-table;
489 vertical-align: middle;
498 // Input groups need that 100% width though
499 .input-group > .form-control {
505 vertical-align: middle;
508 // Remove default margin on radios/checkboxes that were used for stacking, and
509 // then undo the floating of radios and checkboxes to match.
512 display: inline-block;
515 vertical-align: middle;
521 .radio input[type="radio"],
522 .checkbox input[type="checkbox"] {
527 // Re-override the feedback icon.
528 .has-feedback .form-control-feedback {
534 // [converter] extracted as `@mixin form-inline` for libsass compatibility
536 @include form-inline;
541 // Horizontal forms are built on grid classes and allow you to create forms with
542 // labels on the left and inputs on the right.
546 // Consistent vertical alignment of radios and checkboxes
548 // Labels also get some reset styles, but that is scoped to a media query below.
555 padding-top: ($padding-base-vertical + 1); // Default padding plus a border
557 // Account for padding we're adding to ensure the alignment and of help text
558 // and other content below items
561 min-height: ($line-height-computed + ($padding-base-vertical + 1));
564 // Make form groups behave like rows
569 // Reset spacing and right align labels, but scope to media queries so that
570 // labels on narrow viewports stack the same as a default form example.
571 @media (min-width: $screen-sm-min) {
575 padding-top: ($padding-base-vertical + 1); // Default padding plus a border
581 // Reposition the icon because it's now within a grid column and columns have
582 // `position: relative;` on them. Also accounts for the grid gutter padding.
583 .has-feedback .form-control-feedback {
584 right: floor(($grid-gutter-width / 2));
589 // Quick utility class for applying `.input-lg` and `.input-sm` styles to the
590 // inputs and labels within a `.form-group`.
592 @media (min-width: $screen-sm-min) {
594 padding-top: (($padding-large-vertical * $line-height-large) + 1);
595 font-size: $font-size-large;
600 @media (min-width: $screen-sm-min) {
602 padding-top: ($padding-small-vertical + 1);
603 font-size: $font-size-small;