twbs--bootstrap/scss/_forms.scss

335 lines
8.6 KiB
SCSS
Raw Normal View History

2017-10-03 03:34:56 +00:00
// stylelint-disable selector-no-qualifying-type
2016-02-06 20:28:18 +00:00
//
2015-04-18 18:30:29 +00:00
// Textual form controls
//
.form-control {
display: block;
width: 100%;
height: $input-height;
padding: $input-padding-y $input-padding-x;
font-size: $input-font-size;
font-weight: $input-font-weight;
line-height: $input-line-height;
2014-12-02 22:02:35 +00:00
color: $input-color;
background-color: $input-bg;
background-clip: padding-box;
border: $input-border-width solid $input-border-color;
2015-10-28 21:33:48 +00:00
// Note: This has no effect on <select>s in some browsers, due to the limited stylability of `<select>`s in CSS.
@if $enable-rounded {
// Manually use the if/else instead of the mixin to account for iOS override
border-radius: $input-border-radius;
} @else {
// Otherwise undo the iOS default
border-radius: 0;
}
2015-07-04 01:35:46 +00:00
@include box-shadow($input-box-shadow);
@include transition($input-transition);
2015-06-19 06:56:43 +00:00
// Unstyle the caret on `<select>`s in IE10+.
&::-ms-expand {
background-color: transparent;
2015-06-19 07:14:36 +00:00
border: 0;
2015-06-19 06:56:43 +00:00
}
// Customize the `:focus` state to imitate native WebKit styles.
2014-12-02 22:02:35 +00:00
@include form-control-focus();
2013-11-02 08:35:51 +00:00
// Placeholder
&::placeholder {
color: $input-placeholder-color;
// Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526.
opacity: 1;
}
2013-11-02 08:35:51 +00:00
// Disabled and read-only inputs
//
// 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.
&:disabled,
&[readonly] {
background-color: $input-disabled-bg;
// iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
opacity: 1;
}
2015-03-01 22:11:22 +00:00
}
select.form-control {
&:focus::-ms-value {
// Suppress the nested default white text on blue background highlight given to
// the selected option text when the (still closed) <select> receives focus
// in IE and (under certain conditions) Edge, as it looks bad and cannot be made to
// match the appearance of the native widget.
// See https://github.com/twbs/bootstrap/issues/19398.
color: $input-color;
background-color: $input-bg;
}
}
// Make file inputs better match text inputs by forcing them to new lines.
2015-04-18 18:30:29 +00:00
.form-control-file,
.form-control-range {
display: block;
width: 100%;
}
2015-04-23 07:51:39 +00:00
//
// Labels
//
Remove .col-form-legend in favor of .col-form-label (#24932) * chore: sync with twbs (#1) * Make styling of grouped option buttons class-based Referencing #23728, styling grouped radio and checkbox buttons should not require the data-toggle attribute. * Fix installing deps in our webpack docs * Fix nested cards on card group (#24766) * Update popper.js to v1.12.9. (#24797) * Don't run postcss for `dist/css/*.min.css` files. (#24676) * Change the text color to dark on bg color warning examples (#24805) * Remove unused file and bundle ie-emulation-modes-warning.js with docs.min.js (#24825) * Remove the unused assets/js/ie10-viewport-bug-workaround.js. * Combine ie-emulation-modes-warning.js with docs.min.js. * Typos in grid.md (#24828) Fixed typos in offsetting section of grid.md * Fix dropup example code * Update devDependencies. (#24829) * Add support for fractional viewport widths (zoom/high-dpi displays) (#24299) * Change breakpoint max- calculation to fractional values * Update docs to reflect fractional max-width breakpoint values * Add fractional max-width to offcanvas example * Add documentation and SCSS comment for fractional viewport support * Add a simple script to generate SRI hashes for our assets. (#24814) * Allow us to run our unit test on differents jquery version * Run karma tests in parallel. * Update typography docs (#24863) * closes #24450 * Rewrite custom form check backgrounds (#24697) * Rewrite custom form check backgrounds Previously, this was all just a background-color and background-image. When we restored the gradients though, we had two background-images competing on the same element, causing rendering glitches. This refactors that code, creating a mixin to simplify things, so we can we easily use two background-images (SVG icon and gradient) when -gradients is set to true. Fixes #24598 * restore default vars * Revamp custom check and radio backgrounds Instead of applying multiple background-image's to the same element, we're adding a new ::before pseudo-element to layer the background-images. Gradients go on the .custom-control-indicator while their icons go on the ::before element. This allows us to shave some bytes from when we compile and we previously needed to redeclare the background-image for the icon if you changed the gradient. * remove now unused mixin * mention change in migration docs * lets the centered modal have any height (#24803) * Custom select updates (#24699) * Add support for size attribute on custom selects * Add large custom select, document it and the small variant * fix custom select focus state * fix custom file input focus styles * remove empty line * Update package.json. (#24582) 1. Use the same jQuery version in jspm 2. Update the files to only include the source and dist folders * Use Jekyll's `smartify` filter when possible. (#24866) * Darken outline hover color to match default button hover (#24150) * Fix Issue #24144 Alter button-outline-variant mixin to darken hover and active background in same fashion as filled button. * Fix Issue #24144 Filled button on hover should utilize the same color-yiq mixin so that theme buttons match * default values, fix mixin * rename it * document it * add migration note * fixes #24728 * Remove unused CSS. (#24872) * tab.js: do not remove fade class if there's no initial active pane * Restore currently unused variables (#24891) * Replace lint-vars.sh with a Node.js script. (#24860) Also, include it in the `css` npm script since it's instant. * Fix docs horizontal scrollbar (#24878) * Fix docs horizontal scrollbar in Components > Modal * Add overflow to docs example class * Drop the handleUpdate() variant While I understand the variant covers the "get a particular plugin instance" case from http://getbootstrap.com/docs/4.0/getting-started/javascript/#programmatic-api it seems weird that we do it here but not everywhere else in the docs (randomly checking other pages, we seem to stick to the documented methods as written on those pages). As this isn't properly explained as is, and as it adds nothing (more of a preference for authors), it would be easier to just drop the variant and stick with the documented method as outlined later on in the same page (avoids having to go off on a "why should you use this instead of that" tangent here). * Combine path and remove variable used in one place. (#24873) * Update devDependencies and gems. (#24876) * Override padding on radio input label (#24899) We could tell folks to nix the class, we could tell them to override it, or we could add another modifier of some kind to address this. None of them seem particularly useful, but the padding override feels the most approachable and clearly documentable. Added this here to close #24844. * Update README.md (#24912) * Work around Travis failures. Note that we should revert this when the issue is fixed. * Revert the Travis workaround. (#24926) The issue has been fixed. * add .col-form-legend-lg and .col-form-legend-sm classes * document .col-form-legend-{size} * trash .col-form-legend completely One class fits all * Update forms.md * consolidate copy * property order
2017-12-02 19:51:38 +00:00
// For use with horizontal and inline forms, when you need the label (or legend)
// text to align with the form controls.
.col-form-label {
padding-top: calc(#{$input-padding-y} + #{$input-border-width});
padding-bottom: calc(#{$input-padding-y} + #{$input-border-width});
Remove .col-form-legend in favor of .col-form-label (#24932) * chore: sync with twbs (#1) * Make styling of grouped option buttons class-based Referencing #23728, styling grouped radio and checkbox buttons should not require the data-toggle attribute. * Fix installing deps in our webpack docs * Fix nested cards on card group (#24766) * Update popper.js to v1.12.9. (#24797) * Don't run postcss for `dist/css/*.min.css` files. (#24676) * Change the text color to dark on bg color warning examples (#24805) * Remove unused file and bundle ie-emulation-modes-warning.js with docs.min.js (#24825) * Remove the unused assets/js/ie10-viewport-bug-workaround.js. * Combine ie-emulation-modes-warning.js with docs.min.js. * Typos in grid.md (#24828) Fixed typos in offsetting section of grid.md * Fix dropup example code * Update devDependencies. (#24829) * Add support for fractional viewport widths (zoom/high-dpi displays) (#24299) * Change breakpoint max- calculation to fractional values * Update docs to reflect fractional max-width breakpoint values * Add fractional max-width to offcanvas example * Add documentation and SCSS comment for fractional viewport support * Add a simple script to generate SRI hashes for our assets. (#24814) * Allow us to run our unit test on differents jquery version * Run karma tests in parallel. * Update typography docs (#24863) * closes #24450 * Rewrite custom form check backgrounds (#24697) * Rewrite custom form check backgrounds Previously, this was all just a background-color and background-image. When we restored the gradients though, we had two background-images competing on the same element, causing rendering glitches. This refactors that code, creating a mixin to simplify things, so we can we easily use two background-images (SVG icon and gradient) when -gradients is set to true. Fixes #24598 * restore default vars * Revamp custom check and radio backgrounds Instead of applying multiple background-image's to the same element, we're adding a new ::before pseudo-element to layer the background-images. Gradients go on the .custom-control-indicator while their icons go on the ::before element. This allows us to shave some bytes from when we compile and we previously needed to redeclare the background-image for the icon if you changed the gradient. * remove now unused mixin * mention change in migration docs * lets the centered modal have any height (#24803) * Custom select updates (#24699) * Add support for size attribute on custom selects * Add large custom select, document it and the small variant * fix custom select focus state * fix custom file input focus styles * remove empty line * Update package.json. (#24582) 1. Use the same jQuery version in jspm 2. Update the files to only include the source and dist folders * Use Jekyll's `smartify` filter when possible. (#24866) * Darken outline hover color to match default button hover (#24150) * Fix Issue #24144 Alter button-outline-variant mixin to darken hover and active background in same fashion as filled button. * Fix Issue #24144 Filled button on hover should utilize the same color-yiq mixin so that theme buttons match * default values, fix mixin * rename it * document it * add migration note * fixes #24728 * Remove unused CSS. (#24872) * tab.js: do not remove fade class if there's no initial active pane * Restore currently unused variables (#24891) * Replace lint-vars.sh with a Node.js script. (#24860) Also, include it in the `css` npm script since it's instant. * Fix docs horizontal scrollbar (#24878) * Fix docs horizontal scrollbar in Components > Modal * Add overflow to docs example class * Drop the handleUpdate() variant While I understand the variant covers the "get a particular plugin instance" case from http://getbootstrap.com/docs/4.0/getting-started/javascript/#programmatic-api it seems weird that we do it here but not everywhere else in the docs (randomly checking other pages, we seem to stick to the documented methods as written on those pages). As this isn't properly explained as is, and as it adds nothing (more of a preference for authors), it would be easier to just drop the variant and stick with the documented method as outlined later on in the same page (avoids having to go off on a "why should you use this instead of that" tangent here). * Combine path and remove variable used in one place. (#24873) * Update devDependencies and gems. (#24876) * Override padding on radio input label (#24899) We could tell folks to nix the class, we could tell them to override it, or we could add another modifier of some kind to address this. None of them seem particularly useful, but the padding override feels the most approachable and clearly documentable. Added this here to close #24844. * Update README.md (#24912) * Work around Travis failures. Note that we should revert this when the issue is fixed. * Revert the Travis workaround. (#24926) The issue has been fixed. * add .col-form-legend-lg and .col-form-legend-sm classes * document .col-form-legend-{size} * trash .col-form-legend completely One class fits all * Update forms.md * consolidate copy * property order
2017-12-02 19:51:38 +00:00
margin-bottom: 0; // Override the `<label>/<legend>` default
font-size: inherit; // Override the `<legend>` default
line-height: $input-line-height;
2015-04-23 07:51:39 +00:00
}
.col-form-label-lg {
padding-top: calc(#{$input-padding-y-lg} + #{$input-border-width});
padding-bottom: calc(#{$input-padding-y-lg} + #{$input-border-width});
font-size: $font-size-lg;
line-height: $input-line-height-lg;
}
.col-form-label-sm {
padding-top: calc(#{$input-padding-y-sm} + #{$input-border-width});
padding-bottom: calc(#{$input-padding-y-sm} + #{$input-border-width});
font-size: $font-size-sm;
line-height: $input-line-height-sm;
}
2015-04-23 07:51:39 +00:00
// Readonly controls as plain text
//
// Apply class to a readonly input to make it appear like regular plain
// text (without any border, background color, focus indicator)
.form-control-plaintext {
display: block;
width: 100%;
padding-top: $input-padding-y;
padding-bottom: $input-padding-y;
margin-bottom: 0; // match inputs if this class comes on inputs with default margins
line-height: $input-line-height;
color: $input-plaintext-color;
background-color: transparent;
border: solid transparent;
border-width: $input-border-width 0;
&.form-control-sm,
&.form-control-lg {
padding-right: 0;
padding-left: 0;
}
}
// Form control sizing
//
// Build on `.form-control` with modifier classes to decrease or increase the
// height and font-size of form controls.
//
// Repeated in `_input_group.scss` to avoid Sass extend issues.
.form-control-sm {
height: $input-height-sm;
padding: $input-padding-y-sm $input-padding-x-sm;
font-size: $input-font-size-sm;
line-height: $input-line-height-sm;
@include border-radius($input-border-radius-sm);
}
.form-control-lg {
height: $input-height-lg;
padding: $input-padding-y-lg $input-padding-x-lg;
font-size: $input-font-size-lg;
line-height: $input-line-height-lg;
@include border-radius($input-border-radius-lg);
}
2018-10-22 18:57:09 +00:00
// stylelint-disable-next-line no-duplicate-selectors
select.form-control {
&[size],
&[multiple] {
height: auto;
}
}
2018-10-22 18:57:09 +00:00
// stylelint-disable-next-line no-duplicate-selectors
textarea.form-control {
height: auto;
}
// Form groups
//
// Designed to help with the organization and spacing of vertical forms. For
// horizontal forms, use the predefined grid classes.
.form-group {
2015-03-01 22:11:22 +00:00
margin-bottom: $form-group-margin-bottom;
}
.form-text {
display: block;
2016-12-26 23:42:19 +00:00
margin-top: $form-text-margin-top;
}
// Form grid
//
// Special replacement for our grid system's `.row` for tighter form layouts.
.form-row {
display: flex;
flex-wrap: wrap;
margin-right: -5px;
margin-left: -5px;
> .col,
> [class*="col-"] {
padding-right: 5px;
padding-left: 5px;
}
}
// Checkboxes and radios
//
// Indent the labels to position radios/checkboxes as hanging controls.
.form-check {
position: relative;
display: block;
2016-12-26 23:42:19 +00:00
padding-left: $form-check-input-gutter;
}
.form-check-input {
position: absolute;
2016-12-26 23:42:19 +00:00
margin-top: $form-check-input-margin-y;
margin-left: -$form-check-input-gutter;
&:disabled ~ .form-check-label {
color: $text-muted;
}
}
.form-check-label {
margin-bottom: 0; // Override default `<label>` bottom margin
}
.form-check-inline {
display: inline-flex;
align-items: center;
padding-left: 0; // Override base .form-check
margin-right: $form-check-inline-margin-x;
// Undo .form-check-input defaults and add some `margin-right`.
.form-check-input {
position: static;
margin-top: 0;
margin-right: $form-check-inline-input-margin-x;
margin-left: 0;
}
}
2013-12-15 23:24:52 +00:00
// Form validation
//
// Provide feedback to users when form field values are valid or invalid. Works
// primarily for client-side validation via scoped `:invalid` and `:valid`
// pseudo-classes but also includes `.is-invalid` and `.is-valid` classes for
// server side validation.
@include form-validation-state("valid", $form-feedback-valid-color);
@include form-validation-state("invalid", $form-feedback-invalid-color);
2014-07-03 05:54:56 +00:00
// 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).
.form-inline {
2016-12-22 04:26:17 +00:00
display: flex;
flex-flow: row wrap;
align-items: center; // Prevent shorter elements from growing to same height as others (e.g., small buttons growing to normal sized button height)
2016-12-22 04:26:17 +00:00
// Because we use flex, the initial sizing of checkboxes is collapsed and
// doesn't occupy the full-width (which is what we want for xs grid tier),
// so we force that here.
.form-check {
width: 100%;
}
2013-08-05 18:47:12 +00:00
// Kick in the inline
@include media-breakpoint-up(sm) {
label {
2016-12-22 04:26:17 +00:00
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 0;
}
// Inline-block all the things for "inline"
.form-group {
2016-12-22 04:26:17 +00:00
display: flex;
flex: 0 0 auto;
flex-flow: row wrap;
align-items: center;
margin-bottom: 0;
}
2015-12-08 07:52:10 +00:00
// Allow folks to *not* use `.form-group`
.form-control {
display: inline-block;
width: auto; // Prevent labels from stacking above inputs in `.form-group`
vertical-align: middle;
}
// Make static controls behave like regular ones
2017-06-26 14:59:20 +00:00
.form-control-plaintext {
display: inline-block;
}
.input-group,
.custom-select {
width: auto;
}
// Remove default margin on radios/checkboxes that were used for stacking, and
// then undo the floating of radios and checkboxes to match.
.form-check {
2016-12-22 04:26:17 +00:00
display: flex;
align-items: center;
justify-content: center;
width: auto;
padding-left: 0;
}
.form-check-input {
position: relative;
2016-12-27 00:11:50 +00:00
margin-top: 0;
margin-right: $form-check-input-margin-x;
margin-left: 0;
}
.custom-control {
2016-12-22 04:26:17 +00:00
align-items: center;
justify-content: center;
}
.custom-control-label {
margin-bottom: 0;
}
2014-12-02 22:02:35 +00:00
}
}