Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get button groups that span the full width of a parent in Bootstrap?

In Bootstrap, how can I get a button group like the following that span the full width of a parent element? (like with the ".btn-block" class, but applied to a group http://getbootstrap.com/css/#buttons-sizes )

<div class="btn-group" role="group" aria-label="...">   <button type="button" class="btn btn-default">Left</button>   <button type="button" class="btn btn-default">Middle</button>   <button type="button" class="btn btn-default">Right</button> </div> 
like image 239
Max Avatar asked May 12 '16 14:05

Max


People also ask

What class allows you to create a button that spans the entire width of the parent element?

Add class . btn-block to create a block level button that spans the entire width of the parent element.

How can set full width button in Bootstrap?

How can set full width button in Bootstrap? Create block level buttons—those that span the full width of a parent—by adding . btn-block .

How do you make a button occupy full width?

For full- width button, we have used width:100% and display: block .

How do I get my Bootstrap buttons the same size or width?

How do I get my bootstrap buttons the same size or width ? Use btn-block, (other optional elements below are: btn-lg for large and btn-primary for blue primary buttons. Use col-sm-4 for narrow and col-sm-12 or entire row for full length buttons.


1 Answers

Correct solution for Bootstrap 4 and Bootstrap 5 (from Bootstrap 4 migration documentation):

Removed .btn-group-justified. As a replacement you can use <div class="btn-group d-flex" role="group"></div> as a wrapper around elements with .w-100.

Example:

<div class="btn-group d-flex" role="group" aria-label="...">   <button type="button" class="btn btn-default w-100">Left</button>   <button type="button" class="btn btn-default w-100">Middle</button>   <button type="button" class="btn btn-default w-100">Right</button> </div> 

Source: https://getbootstrap.com/docs/4.0/migration/#button-group

Edit: verified solution with Bootstrap 5

like image 68
Diego P. Steiner Avatar answered Sep 18 '22 13:09

Diego P. Steiner