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