Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent bootstrap button groups from breaking

How can I prevent bootstrap button goups from breaking in to 2 lines when there is less space?

I am trying to use the below Bootstrap code:

   <div class="btn-group" style=" width:100px ;">
        <button type="button" class="btn btn-default" style=" width:30px;">-</button>
        <input type="text" class="form-control" style="width:30px;">   
        <button type="button" class="btn btn-default" style=" width:30px;"> +</button>
    </div>

And it looks like:

enter image description here

like image 880
shmulik hazan Avatar asked Apr 19 '14 08:04

shmulik hazan


People also ask

How to group buttons together in Bootstrap 5?

Bootstrap 5 allows you to group a series of buttons together (on a single line) in a button group: Use a <div> element with class .btn-group to create a button group:

What is the use of button group in HTML?

Button group wraps a series of buttons together into a single line (navbar} or stack in a vertical column. Many examples and simple tutorials. Group a series of buttons together on a single line with the button group. Wrap a series of buttons with .btn in .btn-group.

How to span the entire width of the screen in Bootstrap?

To span the entire width of the screen, use the .btn-group-justified class: Note: For <button> elements, you must wrap each button in a .btn-group class: Add a Bootstrap class to group the buttons together.

How do I Group a series of buttons together?

Group a series of buttons together on a single line with the button group. Wrap a series of buttons with .btn in .btn-group. In order for assistive technologies (such as screen readers) to convey that a series of buttons is grouped, an appropriate role attribute needs to be provided.


1 Answers

This is what worked for me, turn the group of buttons to a flex item (by default it does not wrap):

.btn-group {
  display: flex;
}

I saw this here, and there are more options too: https://github.com/twbs/bootstrap/issues/9939

like image 146
bets Avatar answered Oct 06 '22 05:10

bets