mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-02 14:24:19 +01:00
3e2f9ab237
* v5: Promote floating labels example to component - Adds new .form-floating - Stubs out basics of a docs page - Removes existing Example * Update floating labels to support .form-select, make inputs and selects more consistent - To do this, I made the .form-control and .form-select consistent in min-height vs height - Removed some unused variables now - Updated -color to be the -color because I don't know why this was any different before - Update page to include some examples for layout, validation, and value - Rewrite styles to not modify padding, but instead transform and opacity * Streamline and bulletproof some things - Apply some optimizations from code review - Removed unecessary properties from the label - Add some comments for what properties are required - Move from fixed height for labels to height 100% so we can support textareas - Improve docs a little bit, add ToC * Move some values to variables, switch from scaling font-size to scale, update transforms * Bring over changes from #30966 and add to them to tighten things up * Delete the now unused example images * Fix typo * Allowlist the calc function * Add transform-origin, update transform values * Test out autofill fix * Fix linter issue * Mention it in the migration guide * Bump bundlesize * Add one more variable per review * Shave .25rem off the height Co-authored-by: XhmikosR <xhmikosr@gmail.com>
86 lines
2.2 KiB
SCSS
86 lines
2.2 KiB
SCSS
// stylelint-disable selector-no-vendor-prefix
|
|
|
|
.form-floating {
|
|
position: relative;
|
|
|
|
> .form-control,
|
|
> .form-select {
|
|
height: $form-floating-height;
|
|
padding: $form-floating-padding-y $form-floating-padding-x;
|
|
}
|
|
|
|
> label {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
height: 100%; // allow textareas
|
|
padding: $form-floating-padding-y $form-floating-padding-x;
|
|
pointer-events: none;
|
|
border: $input-border-width solid transparent; // Required for aligning label's text with the input as it affects inner box model
|
|
transform-origin: 0 0;
|
|
@include transition($form-floating-transition);
|
|
}
|
|
|
|
// stylelint-disable no-duplicate-selectors
|
|
> .form-control {
|
|
&::placeholder {
|
|
color: transparent;
|
|
}
|
|
|
|
&:focus,
|
|
&:not(:placeholder-shown) {
|
|
padding-top: $form-floating-input-padding-t;
|
|
padding-bottom: $form-floating-input-padding-b;
|
|
}
|
|
// 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;
|
|
}
|
|
}
|
|
|
|
> .form-select {
|
|
padding-top: $form-floating-input-padding-t;
|
|
padding-bottom: $form-floating-input-padding-b;
|
|
}
|
|
|
|
> .form-control:focus,
|
|
> .form-control:not(:placeholder-shown),
|
|
> .form-select {
|
|
~ label {
|
|
opacity: $form-floating-label-opacity;
|
|
transform: $form-floating-label-transform;
|
|
}
|
|
}
|
|
// Duplicated because `:-webkit-autofill` invalidates other selectors when grouped
|
|
> .form-control:-webkit-autofill {
|
|
~ label {
|
|
opacity: $form-floating-label-opacity;
|
|
transform: $form-floating-label-transform;
|
|
}
|
|
}
|
|
// stylelint-enable no-duplicate-selectors
|
|
}
|
|
|
|
|
|
//
|
|
// Fallback for classic Edge
|
|
//
|
|
|
|
@supports (-ms-ime-align: auto) {
|
|
.form-floating {
|
|
display: flex;
|
|
flex-direction: column-reverse;
|
|
}
|
|
.form-floating > label {
|
|
position: static;
|
|
padding: 0;
|
|
margin-bottom: calc(#{$form-floating-padding-y} / 2); // stylelint-disable-line function-disallowed-list
|
|
border: 0;
|
|
@include transition(none);
|
|
}
|
|
.form-floating > .form-control::-ms-input-placeholder {
|
|
color: $input-placeholder-color;
|
|
}
|
|
}
|