mirror of
https://github.com/twbs/bootstrap.git
synced 2025-10-03 00:03:44 -04:00
Compare commits
5 Commits
6a6687e9c9
...
09520f9d08
Author | SHA1 | Date | |
---|---|---|---|
|
09520f9d08 | ||
|
8446581c3d | ||
|
8915efae15 | ||
|
72ee1af96a | ||
|
f0700c7c3c |
@ -36,21 +36,23 @@
|
|||||||
color: transparent;
|
color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:focus::placeholder {
|
||||||
|
color: $input-placeholder-color;
|
||||||
|
}
|
||||||
|
|
||||||
&:focus,
|
&:focus,
|
||||||
&:not(:placeholder-shown) {
|
&:not(:placeholder-shown) {
|
||||||
padding-top: $form-floating-input-padding-t;
|
@include form-floating-active-input-styles();
|
||||||
padding-bottom: $form-floating-input-padding-b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duplicated because `:-webkit-autofill` invalidates other selectors when grouped
|
// Duplicated because `:-webkit-autofill` invalidates other selectors when grouped
|
||||||
&:-webkit-autofill {
|
&:-webkit-autofill {
|
||||||
padding-top: $form-floating-input-padding-t;
|
@include form-floating-active-input-styles();
|
||||||
padding-bottom: $form-floating-input-padding-b;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> .form-select {
|
> .form-select {
|
||||||
padding-top: $form-floating-input-padding-t;
|
@include form-floating-active-input-styles();
|
||||||
padding-bottom: $form-floating-input-padding-b;
|
|
||||||
padding-left: $form-floating-padding-x;
|
padding-left: $form-floating-padding-x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,13 +61,23 @@
|
|||||||
> .form-control-plaintext,
|
> .form-control-plaintext,
|
||||||
> .form-select {
|
> .form-select {
|
||||||
~ label {
|
~ label {
|
||||||
transform: $form-floating-label-transform;
|
@include form-floating-active-label-styles();
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
position: absolute;
|
||||||
|
inset: $form-floating-padding-y ($form-floating-padding-x * .5);
|
||||||
|
z-index: -1;
|
||||||
|
height: $form-floating-label-height;
|
||||||
|
content: "";
|
||||||
|
background-color: $input-bg;
|
||||||
|
@include border-radius($input-border-radius);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Duplicated because `:-webkit-autofill` invalidates other selectors when grouped
|
// Duplicated because `:-webkit-autofill` invalidates other selectors when grouped
|
||||||
> .form-control:-webkit-autofill {
|
> .form-control:-webkit-autofill {
|
||||||
~ label {
|
~ label {
|
||||||
transform: $form-floating-label-transform;
|
@include form-floating-active-label-styles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
> textarea:focus,
|
> textarea:focus,
|
||||||
@ -95,3 +107,22 @@
|
|||||||
color: $form-floating-label-disabled-color;
|
color: $form-floating-label-disabled-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Todo in v6: Consider combining this with the .form-control-plaintext rules to reduce some CSS?
|
||||||
|
.form-floating-always {
|
||||||
|
&.form-floating,
|
||||||
|
.form-floating {
|
||||||
|
.form-control {
|
||||||
|
@include form-floating-active-input-styles();
|
||||||
|
|
||||||
|
&::placeholder,
|
||||||
|
&:focus::placeholder {
|
||||||
|
color: $input-placeholder-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
@include form-floating-active-label-styles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
// This mixin uses an `if()` technique to be compatible with Dart Sass
|
// This mixin uses an `if()` technique to be compatible with Dart Sass
|
||||||
// See https://github.com/sass/sass/issues/1873#issuecomment-152293725 for more details
|
// See https://github.com/sass/sass/issues/1873#issuecomment-152293725 for more details
|
||||||
|
|
||||||
|
// scss-docs-start form-floating-mixins
|
||||||
|
@mixin form-floating-active-input-styles() {
|
||||||
|
padding-top: $form-floating-input-padding-t;
|
||||||
|
padding-bottom: $form-floating-input-padding-b;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin form-floating-active-label-styles() {
|
||||||
|
color: rgba(var(--#{$prefix}body-color-rgb), #{$form-floating-label-opacity});
|
||||||
|
transform: $form-floating-label-transform;
|
||||||
|
}
|
||||||
|
// scss-docs-end form-floating-mixins
|
||||||
|
|
||||||
// scss-docs-start form-validation-mixins
|
// scss-docs-start form-validation-mixins
|
||||||
@mixin form-validation-state-selector($state) {
|
@mixin form-validation-state-selector($state) {
|
||||||
@if ($state == "valid" or $state == "invalid") {
|
@if ($state == "valid" or $state == "invalid") {
|
||||||
|
@ -129,6 +129,19 @@ When using `.input-group` and `.form-floating` along with form validation, the `
|
|||||||
</div>
|
</div>
|
||||||
</div>`} />
|
</div>`} />
|
||||||
|
|
||||||
|
## Always floating
|
||||||
|
|
||||||
|
Make any `.form-control` always use a floating label with visible placeholder with the `.form-floating-always` modifier class. Visible placeholders use the default input `color` and lighten to the placeholder color on focus. This matches them with other floating labels built with plaintext inputs and selects.
|
||||||
|
|
||||||
|
<Example code={`<div class="form-floating form-floating-always mb-3">
|
||||||
|
<input type="email" class="form-control" id="alwaysFloatingInput" placeholder="name@example.com">
|
||||||
|
<label for="alwaysFloatingInput">Email address</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-floating form-floating-always">
|
||||||
|
<input type="password" class="form-control" id="alwaysFloatingPassword" placeholder="••••••••">
|
||||||
|
<label for="alwaysFloatingPassword">Password</label>
|
||||||
|
</div>`} />
|
||||||
|
|
||||||
## Layout
|
## Layout
|
||||||
|
|
||||||
When working with the Bootstrap grid system, be sure to place form elements within column classes.
|
When working with the Bootstrap grid system, be sure to place form elements within column classes.
|
||||||
@ -158,3 +171,9 @@ When working with the Bootstrap grid system, be sure to place form elements with
|
|||||||
### Sass variables
|
### Sass variables
|
||||||
|
|
||||||
<ScssDocs name="form-floating-variables" file="scss/_variables.scss" />
|
<ScssDocs name="form-floating-variables" file="scss/_variables.scss" />
|
||||||
|
|
||||||
|
### Sass mixins
|
||||||
|
|
||||||
|
<AddedIn version="5.4.0" />
|
||||||
|
|
||||||
|
<ScssDocs name="form-floating-mixins" file="scss/mixins/_forms.scss" removeIndentation={false} />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user