Good morning, I am trying to set up a inline form with inputs of different widths using Bootstrap 4. I have tried the different options available here: http://v4-alpha.getbootstrap.com/components/forms/.
This is as far as I went:
<div class="container">
<div class="row">
<div class="col-xs-1">
<label for="exampleInputName2" class="col-form-label">Name</label>
</div>
<div class="col-xs-2">
<input type="text" class="form-control" placeholder=".col-xs-2">
</div>
<div class="col-xs-3">
<input type="text" class="form-control" placeholder=".col-xs-3">
</div>
<div class="col-xs-4">
<input type="text" class="form-control" placeholder=".col-xs-4">
</div>
</div>
</div>
But I am not using any form classes or tags.
---------------- EDIT ------------------------
To be more specific, how would you specify the widths of labels and inputs in this example coming from the Bootstrap 4 website?
<form class="form-inline">
<div class="form-group">
<label for="exampleInputName2">Name</label>
<input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
</div>
<div class="form-group">
<label for="exampleInputEmail2">Email</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="[email protected]">
</div>
<button type="submit" class="btn btn-primary">Send invitation</button>
</form>
Any good and simple example would be welcome.
Thanks
Sylvain
Set the heights of input elements using classes like . input-lg and . input-sm . Set the widths of elements using grid column classes like .
For default size . form-control is used, for smaller size we can use . form-control class along with . form-control-sm and for larger size we can use .
You can apply the bootstrap classes to make the width responsive. You can give it a border if you want to, to make it look like an input. Use textContent instead of value to access the data, and use the focusout event instead of the change event.
Change the size of the input groups, by adding the relative form sizing classes like . input-group-lg, input-group-sm, input-group-xs to the . input-group itself.
you could also use the Bootstrap 4 width utilities : (.w-25, .w-50, .w-75, .w-100, .mw-100)
<input type="some_type" class="form-control w-25">
See the example below, if you want to use bootstrap v4 grid widths along with the form-inline
<form class="form-inline">
<div class="form-group row">
<div class="col-md-5">
<p class="form-control-static">[email protected]</p>
</div>
<div class="col-md-5">
<input type="password" class="form-control" id="inputPassword2" placeholder="Password">
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-primary">Confirm identity</button>
</div>
</div>
</form>
Check the fiddle for more details: https://jsfiddle.net/dx0dzaqj/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With