问题
I have some problems with getting the bootstrap toolbar to fill 100% from left to right when i use btn-group's
I have tried use: btn-group-justified
Example without btn-group-justified
<div class="btn-toolbar" role="toolbar">
<div class="btn-group">
<button type="button" class="btn btn-default">Left 1</button>
<button type="button" class="btn btn-default">Left 2</button>
<button type="button" class="btn btn-default">Left 3</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-default">Middle 1</button>
<button type="button" class="btn btn-default">Middle 2</button>
<button type="button" class="btn btn-default">Middle 3</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-default">Right 1</button>
<button type="button" class="btn btn-default">Right 2</button>
<button type="button" class="btn btn-default">Right 3</button>
</div>
</div>
Example with btn-group-justified
<div class="btn-toolbar btn-group-justified" role="toolbar">
<div class="btn-group">
<button type="button" class="btn btn-default">Left 1</button>
<button type="button" class="btn btn-default">Left 2</button>
<button type="button" class="btn btn-default">Left 3</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-default">Middle 1</button>
<button type="button" class="btn btn-default">Middle 2</button>
<button type="button" class="btn btn-default">Middle 3</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-default">Right 1</button>
<button type="button" class="btn btn-default">Right 2</button>
<button type="button" class="btn btn-default">Right 3</button>
</div>
</div>
And also the function: width="100%" does not work. any suggestions? or alternatives?
Thanky you.
回答1:
Use btn-block class and col-xx-yy class:
<div class="btn-group btn-block">
<button class="btn btn-default col-lg-4" type="button">Left 1</button>
<button class="btn btn-default col-lg-4" type="button">Left 2</button>
<button class="btn btn-default col-lg-4" type="button">Left 3</button>
</div>
回答2:
I think the solution is to add an extra btn-group div into the hierarchy and use btn-group-justified on that, i.e.
<div class="btn-toolbar" role="toolbar">
<div class="btn-group btn-group-justified">
<div class="btn-group">
<button class="btn btn-default" type="button">Left 1</button>
<button class="btn btn-default" type="button">Left 2</button>
<button class="btn btn-default" type="button">Left 3</button>
</div>
<div class="btn-group">
<button class="btn btn-default" type="button">Middle 1</button>
<button class="btn btn-default" type="button">Middle 2</button>
<button class="btn btn-default" type="button">Middle 3</button>
</div>
<div class="btn-group">
<button class="btn btn-default" type="button">Right 1</button>
<button class="btn btn-default" type="button">Right 2</button>
<button class="btn btn-default" type="button">Right 3</button>
</div>
</div>
</div>
来源:https://stackoverflow.com/questions/26420415/bootstrap-button-toolbar-width-100-using-btn-groups