Возможно, вам придется объединить flex-direction: row-reverse;
и flex-wrap: wrap-reverse;
, чтобы получить то, что вы хотите.
Макет
Чтобы не перепутать со значением по умолчанию Bootstrap стиль, я создал пользовательский класс с именем .btn-group-custom
.
<div class="btn-group btn-group-custom">
<button type="button" class="btn btn-primary">Button 1</button>
<button type="button" class="btn btn-primary">Button 2</button>
<button type="button" class="btn btn-primary">Button 3</button>
<button type="button" class="btn btn-primary">Button 4</button>
<button type="button" class="btn btn-primary">Button 5</button>
<button type="button" class="btn btn-primary">Button 6</button>
<button type="button" class="btn btn-primary">Button 7</button>
<button type="button" class="btn btn-primary">Button 8</button>
<button type="button" class="btn btn-primary">Button 9</button>
<button type="button" class="btn btn-primary">Button 10</button>
<button type="button" class="btn btn-primary">Button 11</button>
</div>
Стили
.btn-group-custom {
/*
* Wrap the overflow in the reverse order so that the "alone" would be on top
* instead of on the bottom
*/
flex-wrap: wrap-reverse;
/*
* You didn't mention where to put the "alone" button so I assumed you want it
* to be on the right side.
* Displaying the whole row in reverse order can achieve that!
*/
flex-direction: row-reverse;
}
.btn-group-custom > .btn {
/* Since you want 5 buttons in a row */
width: 20%;
}
.btn-group-custom > .btn:first-child,
.btn-group-custom > .btn:last-child {
border-radius: 0 !important;
}
/* Optional: to make rounded corner on the first and last child */
.btn-group-custom > .btn:first-child {
border-bottom-right-radius: .25rem !important;
}
.btn-group-custom > .btn:last-child {
border-top-left-radius: .25rem !important;
}
Результат
![enter image description here](https://i.stack.imgur.com/v9zYJ.png)
демо: https://jsfiddle.net/davidliang2008/a3s7zno1/33/