对齐元素(bootstrap 4)

时间:2017-03-11 18:56:56

标签: html css twitter-bootstrap

我不知道如何将它显示在一行中,那该怎么办?我尝试为id =“search”显示内联,但它没有用。

提前致谢。

This is the image of my code

i want to appear like this

<div class="row">
      <div id="search">
        <div class="form-group">
        <input type="text" class="form-control" id="" placeholder="Search by skills/titles">
        </div>
        <div class="dropdown">
        <button class="btn btn-grey dropdown-toggle" type="button" id="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        Select Location
        </button>
        <div class="dropdown-menu" aria-labelledby="about-us">
        <a class="dropdown-item" href="#">Chennai</a>
        <a class="dropdown-item" href="#">Bangalore</a>
        <a class="dropdown-item" href="#">Mumbai</a>
        <a class="dropdown-item" href="#">Delhi</a>
        <a class="dropdown-item" href="#">Cochin</a>
        <a class="dropdown-item" href="#">Hyderabad</a>
        </div>
        </div>
        <button type="button" class="btn btn-outline-danger">Find Jobs</button>
      </div>
    </div>

1 个答案:

答案 0 :(得分:2)

你应该看一下Bootstrap Grid系统,非常有用 https://www.w3schools.com/bootstrap/bootstrap_grid_examples.asp

&#13;
&#13;
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <h1>Option 1 </h1>
  <div class="row">
    <div class="col-md-12 col-xs-12">
      <div class="col-md-6 col-xs-6">
        <input type="text" class="form-control" id="test" placeholder="Search by skills/titles">
      </div>
      <div class="col-md-3 col-xs-3">
        <div class="dropdown">
          <button class="btn btn-grey dropdown-toggle" type="button" id="test1" data-toggle="dropdown"
                  aria-haspopup="true"
                  aria-expanded="false">
            Select Location
          </button>
          <div class="dropdown-menu" aria-labelledby="about-us">
            <a class="dropdown-item" href="#">Chennai</a>
            <a class="dropdown-item" href="#">Bangalore</a>
            <a class="dropdown-item" href="#">Mumbai</a>
            <a class="dropdown-item" href="#">Delhi</a>
            <a class="dropdown-item" href="#">Cochin</a>
            <a class="dropdown-item" href="#">Hyderabad</a>
          </div>
        </div>
      </div>
      <div class="col-md-3 col-xs-3">
        <button type="button" class="btn btn-outline-danger">Find Jobs</button>
      </div>
    </div>
  </div>

  <h1>Option 2 </h1>
  <div class="row">

    <form class="form-inline">
      <div class="form-group">

        <input type="text" class="form-control" id="" placeholder="Search by skills/titles">

      </div>
      <div class="form-group">

        <div class="dropdown">
          <button class="btn btn-grey dropdown-toggle" type="button" id="" data-toggle="dropdown"
                  aria-haspopup="true" aria-expanded="false">
            Select Location
          </button>
          <div class="dropdown-menu" aria-labelledby="about-us">
            <a class="dropdown-item" href="#">Chennai</a>
            <a class="dropdown-item" href="#">Bangalore</a>
            <a class="dropdown-item" href="#">Mumbai</a>
            <a class="dropdown-item" href="#">Delhi</a>
            <a class="dropdown-item" href="#">Cochin</a>
            <a class="dropdown-item" href="#">Hyderabad</a>
          </div>
        </div>
      </div>
      <div class="form-group">
      <button type="submit" class="btn btn-default">Find Jobs</button>
      </div>
    </form>

  </div>
  </div>
</body>
</html>
&#13;
&#13;
&#13;