mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-11 18:02:28 +03:00
Add new form feedback states, clean up existing form styles
New stuff: * Adds `.has-feedback` and `.form-control-feedback` to show icon-based form feedback to users. Fixes #11836. * Removes the `width: 1em` on `.glyphicon` because it makes it impractical to resize the width of all icons, even if they’re not “empty” (e.g., a simple `.glyphicon { width: 30px; }` wouldn’t work, nor would a class preceeded by a parent class. Clean up: * Sets `width: auto;` on all `.form-control`s within inline forms. * Removes all the inline `select` menu `width` styles because all inputs are now `auto`. * Update form states docs to separate out sections better.
This commit is contained in:
+45
-12
@@ -253,15 +253,35 @@ input[type="checkbox"],
|
||||
//
|
||||
// Apply contextual and semantic states to individual form controls.
|
||||
|
||||
// Warning
|
||||
.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: (@line-height-computed + 5); // Height of the `label` and it's margin
|
||||
right: 0;
|
||||
display: block;
|
||||
width: @input-height-base;
|
||||
height: @input-height-base;
|
||||
line-height: @input-height-base;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
// Feedback states
|
||||
.has-warning {
|
||||
.form-control-validation(@state-warning-text; @state-warning-text; @state-warning-bg);
|
||||
}
|
||||
// Error
|
||||
.has-error {
|
||||
.form-control-validation(@state-danger-text; @state-danger-text; @state-danger-bg);
|
||||
}
|
||||
// Success
|
||||
.has-success {
|
||||
.form-control-validation(@state-success-text; @state-success-text; @state-success-bg);
|
||||
}
|
||||
@@ -307,7 +327,7 @@ input[type="checkbox"],
|
||||
// Kick in the inline
|
||||
@media (min-width: @screen-sm) {
|
||||
// Inline-block all the things for "inline"
|
||||
.form-group {
|
||||
.form-group {
|
||||
display: inline-block;
|
||||
margin-bottom: 0;
|
||||
vertical-align: middle;
|
||||
@@ -316,17 +336,13 @@ input[type="checkbox"],
|
||||
// In navbar-form, 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;
|
||||
}
|
||||
|
||||
// Override `width: 100%;` when not within a `.form-group`
|
||||
select.form-control {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
// Override `width: 100%;` when not within a `.form-group`
|
||||
> select.form-control {
|
||||
width: auto;
|
||||
.control-label {
|
||||
margin-bottom: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
// Remove default margin on radios/checkboxes that were used for stacking, and
|
||||
@@ -345,6 +361,14 @@ input[type="checkbox"],
|
||||
float: none;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
// 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 {
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,4 +412,13 @@ input[type="checkbox"],
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
top: 0;
|
||||
right: (@grid-gutter-width / 2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user