shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

_forms.scss (16779B)


      1 //
      2 // Forms
      3 // --------------------------------------------------
      4 
      5 
      6 // Normalize non-controls
      7 //
      8 // Restyle and baseline non-control form elements.
      9 
     10 fieldset {
     11   padding: 0;
     12   margin: 0;
     13   border: 0;
     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.
     17   min-width: 0;
     18 }
     19 
     20 legend {
     21   display: block;
     22   width: 100%;
     23   padding: 0;
     24   margin-bottom: $line-height-computed;
     25   font-size: ($font-size-base * 1.5);
     26   line-height: inherit;
     27   color: $legend-color;
     28   border: 0;
     29   border-bottom: 1px solid $legend-border-color;
     30 }
     31 
     32 label {
     33   display: inline-block;
     34   max-width: 100%; // Force IE8 to wrap long content (see https://github.com/twbs/bootstrap/issues/13141)
     35   margin-bottom: 5px;
     36   font-weight: bold;
     37 }
     38 
     39 
     40 // Normalize form controls
     41 //
     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.
     45 
     46 // Override content-box in Normalize (* isn't specific enough)
     47 input[type="search"] {
     48   @include box-sizing(border-box);
     49 }
     50 
     51 // Position radios and checkboxes better
     52 input[type="radio"],
     53 input[type="checkbox"] {
     54   margin: 4px 0 0;
     55   margin-top: 1px \9; // IE8-9
     56   line-height: normal;
     57 }
     58 
     59 input[type="file"] {
     60   display: block;
     61 }
     62 
     63 // Make range inputs behave like textual form controls
     64 input[type="range"] {
     65   display: block;
     66   width: 100%;
     67 }
     68 
     69 // Make multiple select elements height not fixed
     70 select[multiple],
     71 select[size] {
     72   height: auto;
     73 }
     74 
     75 // Focus for file, radio, and checkbox
     76 input[type="file"]:focus,
     77 input[type="radio"]:focus,
     78 input[type="checkbox"]:focus {
     79   @include tab-focus;
     80 }
     81 
     82 // Adjust output element
     83 output {
     84   display: block;
     85   padding-top: ($padding-base-vertical + 1);
     86   font-size: $font-size-base;
     87   line-height: $line-height-base;
     88   color: $input-color;
     89 }
     90 
     91 
     92 // Common form controls
     93 //
     94 // Shared size and type resets for form controls. Apply `.form-control` to any
     95 // of the following form controls:
     96 //
     97 // select
     98 // textarea
     99 // input[type="text"]
    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"]
    109 // input[type="url"]
    110 // input[type="search"]
    111 // input[type="tel"]
    112 // input[type="color"]
    113 
    114 .form-control {
    115   display: block;
    116   width: 100%;
    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;
    121   color: $input-color;
    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; // Note: This has no effect on <select>s in some browsers, due to the limited stylability of <select>s in CSS.
    126   @include box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
    127   @include transition(border-color ease-in-out .15s, box-shadow ease-in-out .15s);
    128 
    129   // Customize the `:focus` state to imitate native WebKit styles.
    130   @include form-control-focus;
    131 
    132   // Placeholder
    133   @include placeholder;
    134 
    135   // Unstyle the caret on `<select>`s in IE10+.
    136   &::-ms-expand {
    137     border: 0;
    138     background-color: transparent;
    139   }
    140   // Disabled and read-only inputs
    141   //
    142   // HTML5 says that controls under a fieldset > legend:first-child won't be
    143   // disabled if the fieldset is disabled. Due to implementation difficulty, we
    144   // don't honor that edge case; we style them as disabled anyway.
    145   &[disabled],
    146   &[readonly],
    147   fieldset[disabled] & {
    148     background-color: $input-bg-disabled;
    149     opacity: 1; // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655
    150   }
    151 
    152   &[disabled],
    153   fieldset[disabled] & {
    154     cursor: $cursor-disabled;
    155   }
    156 
    157   // [converter] extracted textarea& to textarea.form-control
    158 }
    159 
    160 // Reset height for `textarea`s
    161 textarea.form-control {
    162   height: auto;
    163 }
    164 
    165 
    166 // Search inputs in iOS
    167 //
    168 // This overrides the extra rounded corners on search inputs in iOS so that our
    169 // `.form-control` class can properly style them. Note that this cannot simply
    170 // be added to `.form-control` as it's not specific enough. For details, see
    171 // https://github.com/twbs/bootstrap/issues/11586.
    172 
    173 input[type="search"] {
    174   -webkit-appearance: none;
    175 }
    176 
    177 
    178 // Special styles for iOS temporal inputs
    179 //
    180 // In Mobile Safari, setting `display: block` on temporal inputs causes the
    181 // text within the input to become vertically misaligned. As a workaround, we
    182 // set a pixel line-height that matches the given height of the input, but only
    183 // for Safari. See https://bugs.webkit.org/show_bug.cgi?id=139848
    184 //
    185 // Note that as of 9.3, iOS doesn't support `week`.
    186 
    187 @media screen and (-webkit-min-device-pixel-ratio: 0) {
    188   input[type="date"],
    189   input[type="time"],
    190   input[type="datetime-local"],
    191   input[type="month"] {
    192     &.form-control {
    193       line-height: $input-height-base;
    194     }
    195 
    196     &.input-sm,
    197     .input-group-sm & {
    198       line-height: $input-height-small;
    199     }
    200 
    201     &.input-lg,
    202     .input-group-lg & {
    203       line-height: $input-height-large;
    204     }
    205   }
    206 }
    207 
    208 
    209 // Form groups
    210 //
    211 // Designed to help with the organization and spacing of vertical forms. For
    212 // horizontal forms, use the predefined grid classes.
    213 
    214 .form-group {
    215   margin-bottom: $form-group-margin-bottom;
    216 }
    217 
    218 
    219 // Checkboxes and radios
    220 //
    221 // Indent the labels to position radios/checkboxes as hanging controls.
    222 
    223 .radio,
    224 .checkbox {
    225   position: relative;
    226   display: block;
    227   margin-top: 10px;
    228   margin-bottom: 10px;
    229 
    230   label {
    231     min-height: $line-height-computed; // Ensure the input doesn't jump when there is no text
    232     padding-left: 20px;
    233     margin-bottom: 0;
    234     font-weight: normal;
    235     cursor: pointer;
    236   }
    237 }
    238 .radio input[type="radio"],
    239 .radio-inline input[type="radio"],
    240 .checkbox input[type="checkbox"],
    241 .checkbox-inline input[type="checkbox"] {
    242   position: absolute;
    243   margin-left: -20px;
    244   margin-top: 4px \9;
    245 }
    246 
    247 .radio + .radio,
    248 .checkbox + .checkbox {
    249   margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing
    250 }
    251 
    252 // Radios and checkboxes on same line
    253 .radio-inline,
    254 .checkbox-inline {
    255   position: relative;
    256   display: inline-block;
    257   padding-left: 20px;
    258   margin-bottom: 0;
    259   vertical-align: middle;
    260   font-weight: normal;
    261   cursor: pointer;
    262 }
    263 .radio-inline + .radio-inline,
    264 .checkbox-inline + .checkbox-inline {
    265   margin-top: 0;
    266   margin-left: 10px; // space out consecutive inline controls
    267 }
    268 
    269 // Apply same disabled cursor tweak as for inputs
    270 // Some special care is needed because <label>s don't inherit their parent's `cursor`.
    271 //
    272 // Note: Neither radios nor checkboxes can be readonly.
    273 input[type="radio"],
    274 input[type="checkbox"] {
    275   &[disabled],
    276   &.disabled,
    277   fieldset[disabled] & {
    278     cursor: $cursor-disabled;
    279   }
    280 }
    281 // These classes are used directly on <label>s
    282 .radio-inline,
    283 .checkbox-inline {
    284   &.disabled,
    285   fieldset[disabled] & {
    286     cursor: $cursor-disabled;
    287   }
    288 }
    289 // These classes are used on elements with <label> descendants
    290 .radio,
    291 .checkbox {
    292   &.disabled,
    293   fieldset[disabled] & {
    294     label {
    295       cursor: $cursor-disabled;
    296     }
    297   }
    298 }
    299 
    300 
    301 // Static form control text
    302 //
    303 // Apply class to a `p` element to make any string of text align with labels in
    304 // a horizontal form layout.
    305 
    306 .form-control-static {
    307   // Size it appropriately next to real form controls
    308   padding-top: ($padding-base-vertical + 1);
    309   padding-bottom: ($padding-base-vertical + 1);
    310   // Remove default margin from `p`
    311   margin-bottom: 0;
    312   min-height: ($line-height-computed + $font-size-base);
    313 
    314   &.input-lg,
    315   &.input-sm {
    316     padding-left: 0;
    317     padding-right: 0;
    318   }
    319 }
    320 
    321 
    322 // Form control sizing
    323 //
    324 // Build on `.form-control` with modifier classes to decrease or increase the
    325 // height and font-size of form controls.
    326 //
    327 // The `.form-group-* form-control` variations are sadly duplicated to avoid the
    328 // issue documented in https://github.com/twbs/bootstrap/issues/15074.
    329 
    330 @include input-size('.input-sm', $input-height-small, $padding-small-vertical, $padding-small-horizontal, $font-size-small, $line-height-small, $input-border-radius-small);
    331 .form-group-sm {
    332   .form-control {
    333     height: $input-height-small;
    334     padding: $padding-small-vertical $padding-small-horizontal;
    335     font-size: $font-size-small;
    336     line-height: $line-height-small;
    337     border-radius: $input-border-radius-small;
    338   }
    339   select.form-control {
    340     height: $input-height-small;
    341     line-height: $input-height-small;
    342   }
    343   textarea.form-control,
    344   select[multiple].form-control {
    345     height: auto;
    346   }
    347   .form-control-static {
    348     height: $input-height-small;
    349     min-height: ($line-height-computed + $font-size-small);
    350     padding: ($padding-small-vertical + 1) $padding-small-horizontal;
    351     font-size: $font-size-small;
    352     line-height: $line-height-small;
    353   }
    354 }
    355 
    356 @include input-size('.input-lg', $input-height-large, $padding-large-vertical, $padding-large-horizontal, $font-size-large, $line-height-large, $input-border-radius-large);
    357 .form-group-lg {
    358   .form-control {
    359     height: $input-height-large;
    360     padding: $padding-large-vertical $padding-large-horizontal;
    361     font-size: $font-size-large;
    362     line-height: $line-height-large;
    363     border-radius: $input-border-radius-large;
    364   }
    365   select.form-control {
    366     height: $input-height-large;
    367     line-height: $input-height-large;
    368   }
    369   textarea.form-control,
    370   select[multiple].form-control {
    371     height: auto;
    372   }
    373   .form-control-static {
    374     height: $input-height-large;
    375     min-height: ($line-height-computed + $font-size-large);
    376     padding: ($padding-large-vertical + 1) $padding-large-horizontal;
    377     font-size: $font-size-large;
    378     line-height: $line-height-large;
    379   }
    380 }
    381 
    382 
    383 // Form control feedback states
    384 //
    385 // Apply contextual and semantic states to individual form controls.
    386 
    387 .has-feedback {
    388   // Enable absolute positioning
    389   position: relative;
    390 
    391   // Ensure icons don't overlap text
    392   .form-control {
    393     padding-right: ($input-height-base * 1.25);
    394   }
    395 }
    396 // Feedback icon (requires .glyphicon classes)
    397 .form-control-feedback {
    398   position: absolute;
    399   top: 0;
    400   right: 0;
    401   z-index: 2; // Ensure icon is above input groups
    402   display: block;
    403   width: $input-height-base;
    404   height: $input-height-base;
    405   line-height: $input-height-base;
    406   text-align: center;
    407   pointer-events: none;
    408 }
    409 .input-lg + .form-control-feedback,
    410 .input-group-lg + .form-control-feedback,
    411 .form-group-lg .form-control + .form-control-feedback {
    412   width: $input-height-large;
    413   height: $input-height-large;
    414   line-height: $input-height-large;
    415 }
    416 .input-sm + .form-control-feedback,
    417 .input-group-sm + .form-control-feedback,
    418 .form-group-sm .form-control + .form-control-feedback {
    419   width: $input-height-small;
    420   height: $input-height-small;
    421   line-height: $input-height-small;
    422 }
    423 
    424 // Feedback states
    425 .has-success {
    426   @include form-control-validation($state-success-text, $state-success-text, $state-success-bg);
    427 }
    428 .has-warning {
    429   @include form-control-validation($state-warning-text, $state-warning-text, $state-warning-bg);
    430 }
    431 .has-error {
    432   @include form-control-validation($state-danger-text, $state-danger-text, $state-danger-bg);
    433 }
    434 
    435 // Reposition feedback icon if input has visible label above
    436 .has-feedback label {
    437 
    438   & ~ .form-control-feedback {
    439      top: ($line-height-computed + 5); // Height of the `label` and its margin
    440   }
    441   &.sr-only ~ .form-control-feedback {
    442      top: 0;
    443   }
    444 }
    445 
    446 
    447 // Help text
    448 //
    449 // Apply to any element you wish to create light text for placement immediately
    450 // below a form control. Use for general help, formatting, or instructional text.
    451 
    452 .help-block {
    453   display: block; // account for any element using help-block
    454   margin-top: 5px;
    455   margin-bottom: 10px;
    456   color: lighten($text-color, 25%); // lighten the text some for contrast
    457 }
    458 
    459 
    460 // Inline forms
    461 //
    462 // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
    463 // forms begin stacked on extra small (mobile) devices and then go inline when
    464 // viewports reach <768px.
    465 //
    466 // Requires wrapping inputs and labels with `.form-group` for proper display of
    467 // default HTML form controls and our custom form controls (e.g., input groups).
    468 //
    469 // Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
    470 
    471 // [converter] extracted from `.form-inline` for libsass compatibility
    472 @mixin form-inline {
    473 
    474   // Kick in the inline
    475   @media (min-width: $screen-sm-min) {
    476     // Inline-block all the things for "inline"
    477     .form-group {
    478       display: inline-block;
    479       margin-bottom: 0;
    480       vertical-align: middle;
    481     }
    482 
    483     // In navbar-form, allow folks to *not* use `.form-group`
    484     .form-control {
    485       display: inline-block;
    486       width: auto; // Prevent labels from stacking above inputs in `.form-group`
    487       vertical-align: middle;
    488     }
    489 
    490     // Make static controls behave like regular ones
    491     .form-control-static {
    492       display: inline-block;
    493     }
    494 
    495     .input-group {
    496       display: inline-table;
    497       vertical-align: middle;
    498 
    499       .input-group-addon,
    500       .input-group-btn,
    501       .form-control {
    502         width: auto;
    503       }
    504     }
    505 
    506     // Input groups need that 100% width though
    507     .input-group > .form-control {
    508       width: 100%;
    509     }
    510 
    511     .control-label {
    512       margin-bottom: 0;
    513       vertical-align: middle;
    514     }
    515 
    516     // Remove default margin on radios/checkboxes that were used for stacking, and
    517     // then undo the floating of radios and checkboxes to match.
    518     .radio,
    519     .checkbox {
    520       display: inline-block;
    521       margin-top: 0;
    522       margin-bottom: 0;
    523       vertical-align: middle;
    524 
    525       label {
    526         padding-left: 0;
    527       }
    528     }
    529     .radio input[type="radio"],
    530     .checkbox input[type="checkbox"] {
    531       position: relative;
    532       margin-left: 0;
    533     }
    534 
    535     // Re-override the feedback icon.
    536     .has-feedback .form-control-feedback {
    537       top: 0;
    538     }
    539   }
    540 }
    541 // [converter] extracted as `@mixin form-inline` for libsass compatibility
    542 .form-inline {
    543   @include form-inline;
    544 }
    545 
    546 
    547 
    548 // Horizontal forms
    549 //
    550 // Horizontal forms are built on grid classes and allow you to create forms with
    551 // labels on the left and inputs on the right.
    552 
    553 .form-horizontal {
    554 
    555   // Consistent vertical alignment of radios and checkboxes
    556   //
    557   // Labels also get some reset styles, but that is scoped to a media query below.
    558   .radio,
    559   .checkbox,
    560   .radio-inline,
    561   .checkbox-inline {
    562     margin-top: 0;
    563     margin-bottom: 0;
    564     padding-top: ($padding-base-vertical + 1); // Default padding plus a border
    565   }
    566   // Account for padding we're adding to ensure the alignment and of help text
    567   // and other content below items
    568   .radio,
    569   .checkbox {
    570     min-height: ($line-height-computed + ($padding-base-vertical + 1));
    571   }
    572 
    573   // Make form groups behave like rows
    574   .form-group {
    575     @include make-row;
    576   }
    577 
    578   // Reset spacing and right align labels, but scope to media queries so that
    579   // labels on narrow viewports stack the same as a default form example.
    580   @media (min-width: $screen-sm-min) {
    581     .control-label {
    582       text-align: right;
    583       margin-bottom: 0;
    584       padding-top: ($padding-base-vertical + 1); // Default padding plus a border
    585     }
    586   }
    587 
    588   // Validation states
    589   //
    590   // Reposition the icon because it's now within a grid column and columns have
    591   // `position: relative;` on them. Also accounts for the grid gutter padding.
    592   .has-feedback .form-control-feedback {
    593     right: floor(($grid-gutter-width / 2));
    594   }
    595 
    596   // Form group sizes
    597   //
    598   // Quick utility class for applying `.input-lg` and `.input-sm` styles to the
    599   // inputs and labels within a `.form-group`.
    600   .form-group-lg {
    601     @media (min-width: $screen-sm-min) {
    602       .control-label {
    603         padding-top: ($padding-large-vertical + 1);
    604         font-size: $font-size-large;
    605       }
    606     }
    607   }
    608   .form-group-sm {
    609     @media (min-width: $screen-sm-min) {
    610       .control-label {
    611         padding-top: ($padding-small-vertical + 1);
    612         font-size: $font-size-small;
    613       }
    614     }
    615   }
    616 }