简体   繁体   中英

How to align a checkbox and a form horizontally?

I want to create a form and have a checkbox next to it. Currently, it looks like this:

在此处输入图片说明

So, the checkbox aligns with the form's label ie they are aligned at top but I would like to have both aligned at bottom.

How should this be done?

This is my code:

<!DOCTYPE html>
<html lang="en">
  <head>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
  </head>
  <body>
    <div class="container">
      <div class="header">
        <h3 class="text-muted">Select something!</h3>
      </div>
      <div class="row">
        <div class="form-group col-xs-6">
          <label for="some_selection">Select something</label>
          <select class="form-control" id="some_selection">
            <option selected>--None--</option>
            <option>foo</option>
            <option>bar</option>
          </select>
        </div>
        <div>
        <input class="form-check-input" type="checkbox" value="" id="some_id">I should be far lower
        </div>
      </div>
    </div>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </body>
</html>

Try this

<div class="container">
  <div class="header">
    <h3 class="text-muted">Select something!</h3>
  </div>
  <div class="row">
    <div class="form-group col-xs-12">
      <label for="some_selection">Select something</label>
    </div>
    <div class="col-xs-6">

    <select class="form-control" id="some_selection">
      <option selected>--None--</option>
      <option>foo</option>
      <option>bar</option>
    </select>

  </div>
    <div class="col-xs-6">
    <input class="form-check-input" type="checkbox" value="" id="some_id">I should be far lower
    </div>
  </div>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM