Is there a way to use Bootstrap's form-floating feature with longer labels so that the text box automatically expands to accommodate the text but doesn't cut off on white-space wrap when too long? I'd like to avoid using position-relative to pop it out of flow, as this should be a last resort if form-floating doesn't meet our requirements.
You can see the issue in action on mobile screens or smaller columns in this jsFiddle: https://jsfiddle.net/tzqr36ja/3/.
Below is the current implementation based on Bootstrap's form-floating:
.cms-forms-container .col-sm-6 {
position: relative;
min-height: 1px;
padding-right: 15px;
padding-left: 15px
}
.cms-form-fieldset {
padding: 0;
background-color: inherit;
}
.cms-form-fieldset .cms-forms-field {
margin: 0;
padding-top: 7px;
}
.cms-forms-fieldset .cms-forms-field input,
.cms-forms-fieldset .cms-forms-field textarea,
.cms-forms-fieldset .cms-forms-field select {
max-width: none !important;
width: 100%;
border-radius: 5px;
background: #ffffff;
color: #666666;
position: relative;
-webkit-appearance: none;
margin: 0;
}
.cms-forms-fieldset .cms-forms-field select {
-webkit-appearance: menulist;
padding-right: 5px;
}
.cms-forms-field div label {
vertical-align: bottom;
display: inline-block !important;
}
.form-floating>.form-control {
height: unset;
}
.form-floating>label {
white-space: normal;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="31535e5e45424543504171041f011f03">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="13717c7c67606761726353263d233d21">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<div class="fieldset cms-form-fieldset">
<div class="row">
<div class="cms-forms-container col-12 col-sm-6">
<div class="cms-forms-field custom-label-a">
<div class="cms-forms-field-wrapper form-floating mb-2">
<select class="form-control valid input validation-valid" name="custom-field-a" id="#">
<option>n/a</option>
<option value="Bacon">Bacon</option>
<option value="Pork belly">Pork belly</option>
</select>
<label for="custom-field-a" class="cms-forms-label">
Bacon ipsum dolor amet andouille capicola pork chop fatback filet mignon buffalo burgdoggen.
</label>
</div>
</div>
</div>
</div>
</div>