mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-08 17:22:31 +03:00
Add option for always visible floating labels
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
// We use mixins instead of placeholders as placeholders would combine the selectors when @extend-ed
|
||||
|
||||
@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() {
|
||||
opacity: $form-floating-label-opacity;
|
||||
transform: $form-floating-label-transform;
|
||||
}
|
||||
|
||||
.form-floating {
|
||||
position: relative;
|
||||
|
||||
@@ -30,19 +42,17 @@
|
||||
|
||||
&:focus,
|
||||
&:not(:placeholder-shown) {
|
||||
padding-top: $form-floating-input-padding-t;
|
||||
padding-bottom: $form-floating-input-padding-b;
|
||||
@include form-floating-active-input-styles();
|
||||
}
|
||||
|
||||
// Duplicated because `:-webkit-autofill` invalidates other selectors when grouped
|
||||
&:-webkit-autofill {
|
||||
padding-top: $form-floating-input-padding-t;
|
||||
padding-bottom: $form-floating-input-padding-b;
|
||||
@include form-floating-active-input-styles();
|
||||
}
|
||||
}
|
||||
|
||||
> .form-select {
|
||||
padding-top: $form-floating-input-padding-t;
|
||||
padding-bottom: $form-floating-input-padding-b;
|
||||
@include form-floating-active-input-styles();
|
||||
}
|
||||
|
||||
> .form-control:focus,
|
||||
@@ -50,15 +60,14 @@
|
||||
> .form-control-plaintext,
|
||||
> .form-select {
|
||||
~ label {
|
||||
opacity: $form-floating-label-opacity;
|
||||
transform: $form-floating-label-transform;
|
||||
@include form-floating-active-label-styles();
|
||||
}
|
||||
}
|
||||
|
||||
// Duplicated because `:-webkit-autofill` invalidates other selectors when grouped
|
||||
> .form-control:-webkit-autofill {
|
||||
~ label {
|
||||
opacity: $form-floating-label-opacity;
|
||||
transform: $form-floating-label-transform;
|
||||
@include form-floating-active-label-styles();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,3 +77,21 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Todo in v6: Consider combining this with the .form-control-plaintext rules to reduce some CSS?
|
||||
.form-floating-always {
|
||||
> .form-control {
|
||||
@include form-floating-active-input-styles();
|
||||
|
||||
&::placeholder {
|
||||
color: $input-color;
|
||||
}
|
||||
&:focus::placeholder {
|
||||
color: $input-placeholder-color;
|
||||
}
|
||||
}
|
||||
|
||||
> label {
|
||||
@include form-floating-active-label-styles();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user