Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Bootstrap Form-Input horizontal

Hi,

I want to create a form with horizontal inputs. Also i want to make 2 input fields in one line. Is there a solution to solve this? Thanks :)

2 Answers

If its Twitter Bootstrap, have a look at their website, they show the code on how to use the styles. Its pretty easy http://getbootstrap.com/css/

Otherwise to create an inline form you can do the following you add the class .form-inline to your form and create the bootstrap style form as usual.

With the horizontal form you add the class .form-horizontal to your form. Then you use the column sizes for your labels and inputs as shown below.

<!-- Inline Form -->
<form class="form-inline" role="form">
  <div class="form-group">
     <label class="sr-only" for="exampleInputEmail2">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail2" placeholder="Enter email">
  </div>
  <button type="submit" class="btn btn-default">Sign in</button>
</form>

<!-- Horizontal Form -->
<form class="form-horizontal" role="form">
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default">Sign in</button>
    </div>
  </div>
</form>

Thanks:) I want to create an inline form but put two inputs in one line. I want to create some inputs horizontal and some in one line . (Street and housenumber in one line) It's for a contact-form.

Thanks:)