Question

I have a registration form with the following layout:

.col-lg-4.col-lg-offset-4

  .well
    %legend Create your account

    %form{role: :form, action: '/signup', method: :post}
      .row
        .form-group
          %label.col-xs-4{for: :email} Email
          .col-xs-8
            %input.form-control{id: :email, name: :email, type: :email, autocomplete: :off}
      .row
        .form-group
          %label.col-xs-4{for: :password} Password
          .col-xs-8
            %input.form-control{type: :password, name: :password, id: :password, autocomplete: :off}
      .row
        .form-group
          .col-xs-8.col-lg-offset-4
            %button.btn.btn-primary.btn-block{type: :submit} Create Account
.clearfix

But it doesn't look good (they are too close to each other + some minor issues) because, most probably, I placed form-group, col-xs and row in the wrong order. I tried the different order, though, but the result was more or less the same. I wonder, what have I been doing wrong?

Was it helpful?

Solution

Per the Bootstrap docs, the only allowed first children of the row class are the col- classes:

Content should be placed within columns, and only columns may be immediate children of rows.

Try cleaning up your class assignments and it should render in a more correct manner. If you're going for inline labels, try matching the horizontal form sample markup:

<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">
    <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
    <div class="col-sm-10">
      <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <div class="checkbox">
        <label>
          <input type="checkbox"> Remember me
        </label>
      </div>
    </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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top