prathana dan prathana dan - 9 months ago 26
CSS Question

Aligning the elements(bootstrap 4)

I don't know how to display it in a single line so what should be done? I tried giving display inline for id="search" , but it didn't work.

Thanks in advance.

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>




Answer Source

You should take a look into the Bootstrap Grid system, is very useful https://www.w3schools.com/bootstrap/bootstrap_grid_examples.asp

<!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>