Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Width of inputs in inline form - Bootstrap 4

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

like image 569
Sylvain C. Avatar asked Aug 19 '16 07:08

Sylvain C.


People also ask

How do I change the size of the input box in bootstrap 4?

Set the heights of input elements using classes like . input-lg and . input-sm . Set the widths of elements using grid column classes like .

How do I change the width of a form-control in bootstrap?

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 .

How can make input field responsive in bootstrap 4?

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.

How do I change the input group width?

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.


2 Answers

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">
like image 50
jcjost Avatar answered Sep 21 '22 13:09

jcjost


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/

like image 33
Jerad Rutnam Avatar answered Sep 21 '22 13:09

Jerad Rutnam