Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bring text and button on same line in bootstrap 4

Tags:

bootstrap-4

how to bring the text and button on same line This is the code:

<div class="col-sm-8">
    <h4>Edit Post</h4> 
    <button type="button" class="btn btn-primary" style="display: inline- 
      block;">Add New</button>
</div>
like image 627
Ritz Avatar asked Sep 10 '18 10:09

Ritz


People also ask

How do I align a button to the right side of a text box in Bootstrap?

Bootstrap allows us to align elements by using the utility class float. As we want to align the button to the right side of the text box, we have to use the float-right class.

How do I make two buttons side by side in Bootstrap?

Answer: Use the text-right Class You can simply use the class . text-right on the containing element to right align your Bootstrap buttons within a block box or grid column. It will work in both Bootstrap 3 and 4 versions.


1 Answers

Use the Bootstrap 4 d-inline-block class on the heading...

<div class="col-sm-8">
    <h4 class="d-inline-block">Edit Post</h4>
    <button type="button" class="btn btn-primary">Add New</button>
</div>

Optionally use align-middle to vertically align with the button.

https://www.codeply.com/go/F2uHcAPvmx

like image 106
Zim Avatar answered Dec 31 '22 18:12

Zim