0

I need to do a form with checkboxes and a list. I used Bootstrap for my checkbox and list, but the problem is that the text and the checkbox are unaligned.

enter image description here

<div id="ContForm">
    <div id="Cajamitad1">
      <div class="checkbox">
        <label>
        <input type="checkbox" value="">Soy Vegano
        </label> 
      </div>

      <div class="checkbox">
        <label>
        <input type="checkbox" value="">Soy diabetico
        </label> 
      </div>    
    </div>

    <div id="Cajamitad2">
    <select class="form-control">
            <option>1</option>
            <option>2</option>
    </select>
    </div>

</div>   

How can I align them?

4
  • try putting them both, the label and the checkbox in the class 'form-control'. Commented Mar 17, 2016 at 0:53
  • 1
    Your code looks fine here: bootply.com/pzubYV8xfi, are you using any custom CSS? Commented Mar 17, 2016 at 0:55
  • 1
    Please include your CSS in the question, otherwise we won't be able to answer it. Commented Mar 17, 2016 at 1:11
  • You must have other CSS interfering with the Bootstrap classes as everything looks good in this JSFiddle. Commented Mar 17, 2016 at 3:29

1 Answer 1

1

You can use the classes provided by bootstrap.css like form-control or you can try this:

input {
  vertical-align: middle;
  line-height: 1;
}

This CSS ruleset says,"Every input element will be vertically aligned to the middle, and has the equivalent height of an uppercase letter."

input {
  vertical-align: middle;
  line-height: 1;
}
<div id="ContForm">
  <div id="Cajamitad1">
    <div class="checkbox">
      <label>
        <input type="checkbox" value="">Soy Vegano
      </label>
    </div>

    <div class="checkbox">
      <label>
        <input type="checkbox" value="">Soy Diabetico
      </label>
    </div>
  </div>

  <div id="Cajamitad2">
    <select>
      <option>1</option>
      <option>2</option>
    </select>
  </div>

</div>

Sign up to request clarification or add additional context in comments.

5 Comments

However i am still wondering why there are so many divs nested in eachother.
I see that a lot with Bootstrap markup, doesn't say much semantically. Which by the way is more or less a guideline and not a way of life as some would have others believe. I don't like using a ton of divs, but I try not to push the subject with people new to code, they'll find out how clunky code can get later on like I did.
True, im just glad it isnt just a table, even though it can be extremely convenient for long forms sometimes. Clever use with sections etc. can be of great help too.
I like fieldsets even though Firefox does not.
firefox has more than just one bug tbh. Just read a post about this 3 seconds ago.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.