1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00
twbs--bootstrap/scss/_forms.scss

429 lines
9.8 KiB
SCSS
Raw Normal View History

2016-02-06 15:28:18 -05:00
// scss-lint:disable QualifyingElement
//
2015-04-18 14:30:29 -04:00
// Textual form controls
//
.form-control {
display: block;
width: 100%;
// // Make inputs at least the height of their button counterpart (base line-height + padding + border)
// height: $input-height;
padding: $input-padding-y $input-padding-x;
2014-12-02 17:02:35 -05:00
font-size: $font-size-base;
line-height: $input-line-height;
2014-12-02 17:02:35 -05:00
color: $input-color;
background-color: $input-bg;
// Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214.
background-image: none;
background-clip: padding-box;
border: $input-btn-border-width solid $input-border-color;
2015-10-28 17:33:48 -04: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-03 21:35:46 -04:00
@include box-shadow($input-box-shadow);
@include transition($input-transition);
2015-06-19 02:56:43 -04:00
// Unstyle the caret on `<select>`s in IE10+.
&::-ms-expand {
background-color: transparent;
2015-06-19 03:14:36 -04:00
border: 0;
2015-06-19 02:56:43 -04:00
}
// Customize the `:focus` state to imitate native WebKit styles.
2014-12-02 17:02:35 -05:00
@include form-control-focus();
2013-11-02 04:35:51 -04:00
// Placeholder
&::placeholder {
2014-12-02 17:02:35 -05:00
color: $input-color-placeholder;
// Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526.
opacity: 1;
}
2013-11-02 04:35:51 -04: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] {
2014-12-02 17:02:35 -05:00
background-color: $input-bg-disabled;
// iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
opacity: 1;
}
Merge branch 'master' into v4 Conflicts: .travis.yml Gruntfile.js bower.json dist/css/bootstrap.css dist/css/bootstrap.css.map dist/css/bootstrap.min.css dist/js/bootstrap.js dist/js/bootstrap.min.js docs/_data/glyphicons.yml docs/_includes/components/breadcrumbs.html docs/_includes/components/button-dropdowns.html docs/_includes/components/button-groups.html docs/_includes/components/dropdowns.html docs/_includes/components/glyphicons.html docs/_includes/components/labels.html docs/_includes/components/list-group.html docs/_includes/components/media.html docs/_includes/components/navs.html docs/_includes/components/panels.html docs/_includes/components/progress-bars.html docs/_includes/components/thumbnails.html docs/_includes/components/wells.html docs/_includes/css/buttons.html docs/_includes/css/forms.html docs/_includes/css/helpers.html docs/_includes/css/images.html docs/_includes/css/less.html docs/_includes/customizer-variables.html docs/_includes/getting-started/accessibility.html docs/_includes/getting-started/browser-device-support.html docs/_includes/getting-started/community.html docs/_includes/getting-started/examples.html docs/_includes/getting-started/grunt.html docs/_includes/getting-started/license.html docs/_includes/getting-started/template.html docs/_includes/header.html docs/_includes/js/affix.html docs/_includes/js/alerts.html docs/_includes/js/carousel.html docs/_includes/js/collapse.html docs/_includes/js/dropdowns.html docs/_includes/js/modal.html docs/_includes/js/overview.html docs/_includes/js/popovers.html docs/_includes/js/scrollspy.html docs/_includes/js/tabs.html docs/_includes/js/tooltips.html docs/_includes/js/transitions.html docs/_includes/nav/javascript.html docs/_layouts/default.html docs/assets/css/docs.min.css docs/assets/css/src/docs.css docs/assets/js/customize.min.js docs/assets/js/docs.min.js docs/assets/js/raw-files.min.js docs/assets/js/vendor/FileSaver.js docs/assets/js/vendor/autoprefixer.js docs/assets/js/vendor/uglify.min.js docs/dist/css/bootstrap.css docs/dist/css/bootstrap.css.map docs/dist/css/bootstrap.min.css docs/dist/js/bootstrap.min.js docs/examples/blog/index.html docs/examples/carousel/index.html docs/examples/cover/index.html docs/examples/dashboard/index.html docs/examples/narrow-jumbotron/narrow-jumbotron.css docs/examples/navbar-fixed-top/index.html docs/examples/navbar-static-top/index.html docs/examples/non-responsive/index.html docs/examples/non-responsive/non-responsive.css docs/examples/theme/index.html grunt/configBridge.json js/affix.js js/carousel.js js/collapse.js js/dropdown.js js/modal.js js/popover.js js/scrollspy.js js/tab.js js/tests/unit/affix.js js/tests/unit/button.js js/tests/unit/carousel.js js/tests/unit/modal.js js/tests/unit/tooltip.js js/tooltip.js less/badges.less less/glyphicons.less less/type.less less/variables.less package.json scss/_dropdown.scss scss/_forms.scss test-infra/npm-shrinkwrap.json
2015-03-01 16:44:10 -05:00
&:disabled {
Merge branch 'master' into v4 Conflicts: .travis.yml Gruntfile.js bower.json dist/css/bootstrap.css dist/css/bootstrap.css.map dist/css/bootstrap.min.css dist/js/bootstrap.js dist/js/bootstrap.min.js docs/_data/glyphicons.yml docs/_includes/components/breadcrumbs.html docs/_includes/components/button-dropdowns.html docs/_includes/components/button-groups.html docs/_includes/components/dropdowns.html docs/_includes/components/glyphicons.html docs/_includes/components/labels.html docs/_includes/components/list-group.html docs/_includes/components/media.html docs/_includes/components/navs.html docs/_includes/components/panels.html docs/_includes/components/progress-bars.html docs/_includes/components/thumbnails.html docs/_includes/components/wells.html docs/_includes/css/buttons.html docs/_includes/css/forms.html docs/_includes/css/helpers.html docs/_includes/css/images.html docs/_includes/css/less.html docs/_includes/customizer-variables.html docs/_includes/getting-started/accessibility.html docs/_includes/getting-started/browser-device-support.html docs/_includes/getting-started/community.html docs/_includes/getting-started/examples.html docs/_includes/getting-started/grunt.html docs/_includes/getting-started/license.html docs/_includes/getting-started/template.html docs/_includes/header.html docs/_includes/js/affix.html docs/_includes/js/alerts.html docs/_includes/js/carousel.html docs/_includes/js/collapse.html docs/_includes/js/dropdowns.html docs/_includes/js/modal.html docs/_includes/js/overview.html docs/_includes/js/popovers.html docs/_includes/js/scrollspy.html docs/_includes/js/tabs.html docs/_includes/js/tooltips.html docs/_includes/js/transitions.html docs/_includes/nav/javascript.html docs/_layouts/default.html docs/assets/css/docs.min.css docs/assets/css/src/docs.css docs/assets/js/customize.min.js docs/assets/js/docs.min.js docs/assets/js/raw-files.min.js docs/assets/js/vendor/FileSaver.js docs/assets/js/vendor/autoprefixer.js docs/assets/js/vendor/uglify.min.js docs/dist/css/bootstrap.css docs/dist/css/bootstrap.css.map docs/dist/css/bootstrap.min.css docs/dist/js/bootstrap.min.js docs/examples/blog/index.html docs/examples/carousel/index.html docs/examples/cover/index.html docs/examples/dashboard/index.html docs/examples/narrow-jumbotron/narrow-jumbotron.css docs/examples/navbar-fixed-top/index.html docs/examples/navbar-static-top/index.html docs/examples/non-responsive/index.html docs/examples/non-responsive/non-responsive.css docs/examples/theme/index.html grunt/configBridge.json js/affix.js js/carousel.js js/collapse.js js/dropdown.js js/modal.js js/popover.js js/scrollspy.js js/tab.js js/tests/unit/affix.js js/tests/unit/button.js js/tests/unit/carousel.js js/tests/unit/modal.js js/tests/unit/tooltip.js js/tooltip.js less/badges.less less/glyphicons.less less/type.less less/variables.less package.json scss/_dropdown.scss scss/_forms.scss test-infra/npm-shrinkwrap.json
2015-03-01 16:44:10 -05:00
cursor: $cursor-disabled;
}
2015-03-01 17:11:22 -05:00
}
select.form-control {
2016-02-07 11:21:26 -05:00
&:not([size]):not([multiple]) {
$select-border-width: ($border-width * 2);
height: calc(#{$input-height} + #{$select-border-width});
}
&: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 14:30:29 -04:00
.form-control-file,
.form-control-range {
display: block;
}
2015-04-23 03:51:39 -04:00
//
// Labels
//
// For use with horizontal and inline forms, when you need the label text to
// align with the form controls.
.col-form-label {
padding-top: $input-padding-y;
padding-bottom: $input-padding-y;
2015-04-23 03:51:39 -04:00
margin-bottom: 0; // Override the `<label>` default
}
.col-form-label-lg {
padding-top: $input-padding-y-lg;
padding-bottom: $input-padding-y-lg;
font-size: $font-size-lg;
}
.col-form-label-sm {
padding-top: $input-padding-y-sm;
padding-bottom: $input-padding-y-sm;
font-size: $font-size-sm;
}
2015-04-23 03:51:39 -04:00
2016-02-19 10:35:00 -05:00
//
// Legends
//
// For use with horizontal and inline forms, when you need the legend text to
// be the same size as regular labels, and to align with the form controls.
.col-form-legend {
padding-top: $input-padding-y;
padding-bottom: $input-padding-y;
2016-02-19 10:35:00 -05:00
margin-bottom: 0;
font-size: $font-size-base;
}
2015-04-23 03:51:39 -04:00
// Static form control text
//
// Apply class to an element to make any string of text align with labels in a
// horizontal form layout.
.form-control-static {
padding-top: $input-padding-y;
padding-bottom: $input-padding-y;
line-height: $input-line-height;
border: solid transparent;
border-width: 1px 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.
//
// The `.form-group-* form-control` variations are sadly duplicated to avoid the
// issue documented in https://github.com/twbs/bootstrap/issues/15074.
.form-control-sm {
padding: $input-padding-y-sm $input-padding-x-sm;
font-size: $font-size-sm;
@include border-radius($input-border-radius-sm);
}
select.form-control-sm {
&:not([size]):not([multiple]) {
height: $input-height-sm;
}
}
.form-control-lg {
padding: $input-padding-y-lg $input-padding-x-lg;
font-size: $font-size-lg;
@include border-radius($input-border-radius-lg);
}
select.form-control-lg {
&:not([size]):not([multiple]) {
height: $input-height-lg;
}
}
// 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 17:11:22 -05:00
margin-bottom: $form-group-margin-bottom;
}
.form-text {
display: block;
margin-top: ($spacer * .25);
}
// Checkboxes and radios
//
// Indent the labels to position radios/checkboxes as hanging controls.
.form-check {
position: relative;
display: block;
margin-bottom: ($spacer * .75);
2014-03-10 19:43:57 -04:00
// Move up sibling radios or checkboxes for tighter spacing
2016-05-08 20:11:17 -04:00
+ .form-check {
margin-top: -.25rem;
}
&.disabled {
.form-check-label {
color: $text-muted;
cursor: $cursor-disabled;
}
}
}
.form-check-label {
padding-left: 1.25rem;
margin-bottom: 0; // Override default `<label>` bottom margin
cursor: pointer;
}
.form-check-input {
position: absolute;
margin-top: .25rem;
margin-left: -1.25rem;
&:only-child {
position: static;
}
}
// Radios and checkboxes on same line
.form-check-inline {
display: inline-block;
.form-check-label {
vertical-align: middle;
}
+ .form-check-inline {
margin-left: .75rem;
}
}
2013-12-15 18:24:52 -05:00
// Form control feedback states
//
// Apply contextual and semantic states to individual form controls.
.form-control-feedback {
margin-top: ($spacer * .25);
}
.form-control-success,
.form-control-warning,
2015-11-14 22:45:48 -05:00
.form-control-danger {
padding-right: ($input-padding-x * 3);
2015-08-23 04:00:22 -04:00
background-repeat: no-repeat;
background-position: center right ($input-height / 4);
background-size: ($input-height / 2) ($input-height / 2);
}
2014-12-02 17:02:35 -05:00
// Form validation states
.has-success {
@include form-control-validation($brand-success);
.form-control-success {
2016-02-06 21:05:24 -05:00
background-image: $form-icon-success;
}
}
.has-warning {
@include form-control-validation($brand-warning);
.form-control-warning {
2016-02-06 21:05:24 -05:00
background-image: $form-icon-warning;
}
}
.has-danger {
@include form-control-validation($brand-danger);
2015-11-14 22:45:48 -05:00
.form-control-danger {
2016-02-06 21:05:24 -05:00
background-image: $form-icon-danger;
}
}
2014-07-03 01:54:56 -04: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 {
@if $enable-flex {
display: flex;
flex-flow: row wrap;
// 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 14:47:12 -04:00
// Kick in the inline
@include media-breakpoint-up(sm) {
label {
@if $enable-flex {
display: flex;
align-items: center;
justify-content: center;
}
margin-bottom: 0;
}
// Inline-block all the things for "inline"
.form-group {
@if $enable-flex {
display: flex;
flex: 0 0 auto;
flex-flow: row wrap;
} @else {
display: inline-block;
vertical-align: middle;
}
margin-bottom: 0;
}
2015-12-08 02:52:10 -05: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
.form-control-static {
display: inline-block;
margin-bottom: 0;
}
.input-group {
width: auto;
@if not $enable-flex {
display: inline-table;
vertical-align: middle;
.input-group-addon,
.input-group-btn,
.form-control {
width: auto;
}
}
}
// Input groups need that 100% width though
.input-group > .form-control {
@if not $enable-flex {
width: 100%;
}
}
.form-control-label {
margin-bottom: 0;
vertical-align: middle;
}
// Remove default margin on radios/checkboxes that were used for stacking, and
// then undo the floating of radios and checkboxes to match.
.form-check {
@if $enable-flex {
display: flex;
align-items: center;
justify-content: center;
} @else {
display: inline-block;
vertical-align: middle;
}
width: auto;
margin-top: 0;
margin-bottom: 0;
}
.form-check-label {
padding-left: 0;
}
.form-check-input {
position: relative;
margin-left: 0;
}
// Custom form controls
.custom-control {
padding-left: 0;
@if $enable-flex {
display: flex;
align-items: center;
justify-content: center;
} @else {
vertical-align: middle;
}
}
.custom-control-indicator {
position: static;
display: inline-block;
@if $enable-flex {
margin-right: .25rem; // Flexbox alignment means we lose our HTML space here, so we compensate.
}
vertical-align: text-bottom;
}
2014-07-03 01:54:56 -04:00
// Re-override the feedback icon.
.has-feedback .form-control-feedback {
top: 0;
}
2014-12-02 17:02:35 -05:00
}
}