/* ------------------------------------------------------------------------------ * * # Form related components * * Overrides for bootstrap form related components * * Version: 1.1 * Latest update: Mar 10, 2016 * * ---------------------------------------------------------------------------- */ /* Form controls ----------------------------------*/ // Normalize non-controls // ------------------------- // Legend legend { font-size: @font-size-small; padding-top: (@line-height-computed / 2); padding-bottom: (@line-height-computed / 2); text-transform: uppercase; // Remove top padding in first items fieldset:first-child & { &:first-child { padding-top: 0; } } // Control arrow .control-arrow { float: right; color: @text-muted; &:hover { color: @text-color; } } } // Label label { margin-bottom: @padding-base-vertical; font-weight: 400; } // Normalize form controls // ------------------------- // Multiple select select[multiple], select[size] { height: 200px; // Option option { padding: @padding-base-vertical @padding-base-horizontal; border-radius: @input-border-radius; + option { margin-top: 1px; } } } // Focus for file, radio, and checkbox input[type="file"]:focus, input[type="radio"]:focus, input[type="checkbox"]:focus { outline: 0; } // Remove borders from file input input[type="file"] { &, &:focus { border-color: transparent; .box-shadow(none); } } // Common form controls // ------------------------- .form-control { padding-left: 0; padding-right: 0; border-width: 1px 0; border-color: transparent; border-bottom-color: @input-border; border-radius: 0; .box-shadow(none); // Remove outline and shadow on focus &:focus { outline: 0; border-color: transparent; border-bottom-color: @input-border-highlight-color; .box-shadow(@input-box-shadow); } // Disabled inputs &[disabled], fieldset[disabled] & { border-bottom-style: dashed; color: @text-muted; } // Read-only inputs &[readonly] { border-bottom-style: dashed; border-bottom-color: @input-border; color: @input-color; .box-shadow(none); } } // Form controls options // ------------------------- // Transparent input .form-control-unstyled { padding: 0; border: 0; background-color: transparent; } // Remove inputs shadow in mobile browsers input[type="text"], input[type="password"], input[type="search"], input[type="email"], input[type="number"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="url"], input[type="tel"], textarea { -webkit-appearance: none; } /* Form components ----------------------------------*/ // Form groups // ------------------------- .form-group { margin-bottom: @form-group-margin-bottom; position: relative; // Form group nesting .form-group { &:last-child { margin-bottom: 0; } } // Vertical spacing for stacked columns // // When nested form groups stack, add top margin for each column, except first. @media (max-width: @screen-sm-max) { div[class*="col-md-"]:not(.control-label) + div[class*="col-md-"] { margin-top: @form-group-margin-bottom; } } @media (max-width: @screen-md-max) { div[class*="col-lg-"]:not(.control-label) + div[class*="col-lg-"] { margin-top: @form-group-margin-bottom; } } @media (max-width: @screen-xs-max) { div[class*="col-sm-"]:not(.control-label) + div[class*="col-sm-"] { margin-top: @form-group-margin-bottom; } } } // Floating labels // ------------------------- .form-group-material { // Labels > .control-label { position: relative; top: @padding-base-vertical; margin-bottom: 0; .opacity(0); // Top spacing for contextual icon ~ .form-control-feedback { top: @line-height-computed; } // If label has bottom margin &.has-margin { margin-bottom: @padding-base-vertical; // Top spacing for contextual icon ~ .form-control-feedback { top: (@line-height-computed + @padding-base-vertical); } } } // Display label > .control-label.is-visible { top: 0; .opacity(1); } // Label animation > .control-label.animate { .transition(all linear 0.1s); } } // Checkboxes and radios // ------------------------- // Containers .radio, .checkbox { // Make them vertically centered depending on the base input height margin-top: ((@input-height-base - @line-height-computed) / 2); margin-bottom: ((@input-height-base - @line-height-computed) / 2); // Inner label element label { padding-left: (@checkbox-size + @content-padding-small); } } // Checkbox and radio inputs .radio input[type="radio"], .radio-inline input[type="radio"], .checkbox input[type="checkbox"], .checkbox-inline input[type="checkbox"] { margin-left: 0; left: 0; } // Siblings .radio + .radio, .checkbox + .checkbox { margin-top: 0; } // Radios and checkboxes on same line .radio-inline, .checkbox-inline { position: relative; padding-left: (@checkbox-size + @content-padding-small); } // // Right position // // Radio .radio-right { &.radio-inline, label { padding-left: 0; padding-right: (@checkbox-size + @content-padding-small); } input[type="radio"] { left: auto; right: 0; } } // Checkbox .checkbox-right:extend(.radio-right all) { &.checkbox-inline, label { &:extend(.radio-right.radio-inline); } input[type="checkbox"] { &:extend(.radio-right input[type="radio"]); } } // Inline siblings .radio-inline + .radio-inline, .checkbox-inline + .checkbox-inline { margin-left: @content-padding-base; } // Disabled state .radio, .checkbox { &, &-inline { &.disabled, fieldset[disabled] & { color: @gray-light; } } } /* Form control sizing ----------------------------------*/ // The `.form-group-* form-control` variations are sadly duplicated to avoid the // issue documented in https://github.com/twbs/bootstrap/issues/15074. // XLarge .input-xlg { .input-size(@input-height-xlarge; @padding-xlarge-vertical; 0; @font-size-xlarge; @line-height-xlarge; 0); } .form-group-xlg { .form-control { height: @input-height-xlarge; padding: @padding-xlarge-vertical 0; font-size: @font-size-xlarge; line-height: @line-height-xlarge; } .form-control-static { height: @input-height-xlarge; min-height: (@line-height-computed + @font-size-xlarge); padding: @padding-xlarge-vertical 0; font-size: @font-size-xlarge; line-height: @line-height-xlarge; } } // Large .input-lg { padding-left: 0; padding-right: 0; border-radius: 0; } .form-group-lg { .form-control { padding-left: 0; padding-right: 0; border-radius: 0; } .form-control-static { padding-left: 0; padding-right: 0; } } // Small .input-sm { padding-left: 0; padding-right: 0; border-radius: 0; } .form-group-sm { .form-control { padding-left: 0; padding-right: 0; border-radius: 0; } .form-control-static { padding-left: 0; padding-right: 0; } } // Mini .input-xs { .input-size(@input-height-mini; @padding-xs-vertical; 0; @font-size-small; @line-height-small; 0); } .form-group-xs { .form-control { height: @input-height-mini; padding: @padding-xs-vertical 0; font-size: @font-size-small; line-height: @line-height-small; } .form-control-static { height: @input-height-mini; min-height: (@line-height-computed + @font-size-small); padding: @padding-xs-vertical 0; font-size: @font-size-small; line-height: @line-height-small; } } /* Form helpers ----------------------------------*/ // Form control feedback states // ------------------------- // Default right icon position .has-feedback { // Ensure icons don't overlap text .form-control { padding-right: @icon-font-size + @padding-base-horizontal; &.input-xlg { padding-right: @icon-font-size + @padding-xlarge-horizontal; } &.input-lg { padding-right: @icon-font-size + @padding-large-horizontal; } &.input-sm { padding-right: @icon-font-size + @padding-small-horizontal; } &.input-xs { padding-right: @icon-font-size + @padding-xs-horizontal; } } // Inside form groups &.input-group .form-control { &:extend(.has-feedback .form-control); } &.input-group-xlg .form-control { &:extend(.has-feedback .form-control.input-xlg); } &.input-group-lg .form-control { &:extend(.has-feedback .form-control.input-lg); } &.input-group-sm .form-control { &:extend(.has-feedback .form-control.input-sm); } &.input-group-xs .form-control { &:extend(.has-feedback .form-control.input-xs); } } // Feedback icon .form-control-feedback { width: @icon-font-size; color: @input-color; z-index: 3; // Inside input group .input-group > & { height: @input-height-base; line-height: @input-height-base; } } // Left icon position .has-feedback-left { // Ensure icons don't overlap text .form-control { padding-right: 0!important; padding-left: @icon-font-size + @padding-base-horizontal; &.input-xlg { padding-left: @icon-font-size + @padding-xlarge-horizontal; } &.input-lg { padding-left: @icon-font-size + @padding-large-horizontal; } &.input-sm { padding-left: @icon-font-size + @padding-small-horizontal; } &.input-xs { padding-left: @icon-font-size + @padding-xs-horizontal; } } // Inside form groups &.input-group .form-control { &:extend(.has-feedback-left .form-control); } &.input-group-xlg .form-control { &:extend(.has-feedback-left .form-control.input-xlg); } &.input-group-lg .form-control { &:extend(.has-feedback-left .form-control.input-lg); } &.input-group-sm .form-control { &:extend(.has-feedback-left .form-control.input-sm); } &.input-group-xs .form-control { &:extend(.has-feedback-left .form-control.input-xs); } // Feedback .form-control-feedback { right: auto; left: 0; } } // // Sizing // // XLarge .input-xlg + .form-control-feedback, .form-group-xlg > .form-control-feedback, .input-group-xlg > .form-control-feedback { height: @input-height-xlarge; line-height: @input-height-xlarge; } // Large .input-lg + .form-control-feedback, .form-group-lg > .form-control-feedback { width: @icon-font-size; } .input-group-lg > .form-control-feedback { height: @input-height-large; line-height: @input-height-large; } // Small .input-sm + .form-control-feedback, .form-group-sm > .form-control-feedback { width: @icon-font-size; } .input-group-sm > .form-control-feedback { height: @input-height-small; line-height: @input-height-small; } // Mini .input-xs + .form-control-feedback, .form-group-xs > .form-control-feedback, .input-group-xs > .form-control-feedback { height: @input-height-mini; line-height: @input-height-mini; } // // Feedback states // .has-success .form-control { border-color: transparent transparent @state-success-text; .box-shadow(none); &:focus { border-color: transparent transparent @state-success-text; .box-shadow(0 1px 0 @state-success-text); } } .has-warning .form-control { border-color: transparent transparent @state-warning-text; .box-shadow(none); &:focus { border-color: transparent transparent @state-warning-text; .box-shadow(0 1px 0 @state-warning-text); } } .has-error .form-control { border-color: transparent transparent @state-danger-text; .box-shadow(none); &:focus { border-color: transparent transparent @state-danger-text; .box-shadow(0 1px 0 @state-danger-text); } } // Help text // ------------------------- // Block helpers .help-block { color: @text-muted; font-size: @font-size-small; margin-top: @padding-base-vertical; margin-bottom: @padding-base-vertical; } // Inline helpers .help-inline { display: inline-block; color: @text-muted; font-size: @font-size-small; margin-top: (@padding-base-vertical + 1); margin-bottom: (@padding-base-vertical + 1); // Remove gutter if inside column .form-horizontal .form-group > div[class*="col-"] + & { margin-left: (@grid-gutter-width / 2); margin-right: (@grid-gutter-width / 2); } // Inline help works only on large screens @media (min-width: @screen-md) { display: inline-block; margin-top: (@padding-base-vertical + 1); margin-bottom: (@padding-base-vertical + 1); vertical-align: top; // Inline text helper &:not(.label) { color: @text-muted } // In large group .form-group-lg & { margin-top: (@padding-large-vertical + 1); } // In small group .form-group-sm & { margin-top: (@padding-small-vertical + 1); } // In mini group .form-group-xs & { margin-top: (@padding-xs-vertical + 1); } } } /* Form layouts ----------------------------------*/ // Inline forms // ------------------------- .form-inline { @media (min-width: @screen-sm-min) { // Inline-block all the things for "inline" .form-group { & + .form-group { margin-left: @content-padding-base; } // Label setup > label { margin-right: @element-horizontal-spacing; position: relative; top: 1px; } } } } // Horizontal forms // ------------------------- .form-horizontal { // Make form groups behave like rows .form-group { // Nesting .form-group { margin-left: 0; margin-right: 0; } } // Control label @media (min-width: @screen-sm-min) { .control-label { padding-bottom: @padding-base-vertical; padding-top: 0; &:not(.text-right) { text-align: left; } } } // Bottom padding for stacked control labels .control-label { @media (min-width: @screen-xs-min) { &[class*=col-xs-] { padding-top: (@padding-base-vertical + 1); } } @media (min-width: @screen-md-min) { &[class*=col-md-] { padding-top: (@padding-base-vertical + 1); } } @media (min-width: @screen-sm-min) { &[class*=col-sm-] { padding-top: (@padding-base-vertical + 1); } } @media (min-width: @screen-lg-min) { &[class*=col-lg-] { padding-top: (@padding-base-vertical + 1); } } } // Validation state icons .has-feedback { > .form-control-feedback { right: 0; } } .has-feedback-left { .form-control-feedback { right: auto; left: floor((@grid-gutter-width / 2)); } > .form-control-feedback { left: 0; } } // // Form group sizes // // XLarge .form-group-xlg { @media (min-width: @screen-sm-min) { .control-label { font-size: @font-size-xlarge; padding-top: (@padding-xlarge-vertical + 1); } } } // Large .form-group-lg { @media (min-width: @screen-sm-min) { .control-label { padding-top: (@padding-large-vertical + 1); } } } // Small .form-group-sm { @media (min-width: @screen-sm-min) { .control-label { padding-top: (@padding-small-vertical + 1); } } } // Mini .form-group-xs { @media (min-width: @screen-sm-min) { .control-label { font-size: @font-size-small; padding-top: (@padding-xs-vertical + 1); } } } }