9

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>
Red
  • 6,599
  • 9
  • 43
  • 85
Victor Johnson
  • 619
  • 2
  • 6
  • 10

5 Answers5

12

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>
Nandita Sharma
  • 13,287
  • 2
  • 22
  • 35
  • "For Bootstrap-5 we have to use ms-auto instead of ml-auto", source: https://stackoverflow.com/a/65562241/1956540 – BatteryAcid Feb 02 '22 at 18:27
5

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>
Pere Joan Martorell
  • 2,608
  • 30
  • 29
Red
  • 6,599
  • 9
  • 43
  • 85
1

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>
Ali
  • 1,326
  • 1
  • 17
  • 38
0

Try:

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

button {
  float: right;
}

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

billy.farroll
  • 1,903
  • 2
  • 15
  • 23
-1

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.

omikes
  • 8,064
  • 8
  • 37
  • 50
  • 2
    While I appreciate the cute sentiment, it'd be a lot more helpful to the OP if you explained using the correct terminology. (Particularly as it's not entirely clear what you mean when you say they like to *'isolate themselves'*) – George Jun 07 '18 at 11:55
  • i meant they demand to sit alone in the corner in the cafeteria, unless you yell at them to stay `in-line`. come to thing of it, that whole crew of h tags are quite antisocial. it must be genetic. – omikes Jun 07 '18 at 12:00