How is it possible to restrict the width of the .form-text
based on the width of the above input?
I'd like to layout an <input>
in a Bootstrap application with a .form-text
for some additional information. The <input>
and .form-text
are part of a grid layout (spanning multiple columns). The text that is shown inside the .form-text
-styled <div>
is dynamically changing which can, depending on its size, extend the grid's column.
Following this example (https://getbootstrap.com/docs/5.3/forms/overview/#overview)
<form class='ref-table'>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<div id="emailHelp" class="form-text">We'll never share your email with anyone else. We'll never share your email with anyone else. We'll never share your email with anyone else.</div>
</div>
</form>
I noticed that the .form-text
and the <input>
are both kept at the same width. When I add style='width: auto'
to the <input>
, the form-text spans beyond the input, but ideally, the text should wrap under the input (using the input's width as its width).