Victor Johnson
Victor Johnson

Reputation: 659

How to align the header and button on the same line using bootstrap 4

I want to position my h3 header and button on the same line

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="container">
  <div class="get-quote">
    <div class="row">
      <div class="col-md-12">
        <h3 id="quote">IN HOUSE EMBROIDERY AND HEAT TRASNFER</h3> <button type="button" class="pull-right" class="btn btn-primary">Get Quote</button>
      </div>
    </div>
  </div>
</div>

Upvotes: 10

Views: 15328

Answers (5)

Red
Red

Reputation: 7324

You can just use two .col-'s, to place them on one line.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="container">
    <div class="get-quote">
        <div class="row">
            <div class="col-sm-10 col-12">
                <h3 id="quote">IN HOUSE EMBROIDERY AND HEAT TRASNFER</h3>
            </div>
            <div class="col-sm-2 col-12">
                <button type="button" class="btn btn-primary pull-right">Get Quote</button>
            </div>
        </div>
    </div>
</div>

Upvotes: 5

Nandita Sharma
Nandita Sharma

Reputation: 13407

Add d-flex class on col-md-12 div.

Also add ml-auto on button to right align the button

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="container">
  <div class="get-quote">
    <div class="row">
      <div class="col-md-12 d-flex">
        <h3 id="quote">IN HOUSE EMBROIDERY AND HEAT TRASNFER</h3> 
       <button type="button" class="btn btn-primary ml-auto">Get Quote</button>
      </div>
    </div>
  </div>
</div>

Upvotes: 13

omikes
omikes

Reputation: 8513

h3's are notoriously shy and like to isolate themselves. encourage him to get out there and make friends with the button by adding style="display:inline-block" to h3's parameters.

Upvotes: -1

Ali
Ali

Reputation: 1336

Just add display: inline-block; for your h3.

h3 {
  display: inline-block;
}
<div class="container">
  <div class="get-quote">
    <div class="row">
      <div class="col-md-12">
        <h3 id="quote">IN HOUSE EMBROIDERY AND HEAT TRASNFER</h3> <button type="button" class="pull-right" class="btn btn-primary">Get Quote</button>


      </div>
    </div>
  </div>
</div>

Upvotes: 1

billy.farroll
billy.farroll

Reputation: 1921

Try:

h3 {
  margin: 0;
  display: inline-block;
}

button {
  float: right;
}

But, you are using Bootstrap, so perhaps: col-md-6 for both?

Upvotes: 0

Related Questions