Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap full width buttons .btn-group-vertical

<div class="container">
<div class="btn-group-vertical">
<a href="3overview.php" class="btn btn-primary">Overview</a>
<a href="" class="btn btn-primary">Button</a>
<a href="" class="btn btn-primary">Button</a>
<a href="" class="btn btn-primary">Button</a>
<br>
<a href="" class="btn btn-warning">Button</a>
<a href="" class="btn btn-danger">Button</a>
</div>
</div>

I am trying to make it so these buttons are full-width of the container that they are in but I can't seem to get it to work, I have tried .btn-group-justified but nothing works with .btn-group-vertical. Can someone help?

EDIT 11/28/2017: Marked the accepted answer and fixed some typos I found.

like image 340
Firedare Games Avatar asked Dec 21 '16 14:12

Firedare Games


People also ask

How do I create a vertical button group in Bootstrap?

Use the class .btn-group-vertical to create a vertical button group: 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.

What is BTN-group-vertical Bootstrap web development CSS?

Bootstrap class btn-group-vertical Bootstrap Web Development CSS Framework The btn-group-vertical class makes a set of buttons appear vertically stacked rather than horizontally. You can try to run the following code to work with vertical button 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 make a group of buttons span the screen?

Tip: Instead of applying button sizes to every button in a group, use class .btn-group-lg|sm|xs to size all buttons in the group: Use the class .btn-group-vertical to create a vertical button group: To span the entire width of the screen, use the .btn-group-justified class:


1 Answers

The btn-group-vertical has an automatic set width of 85px as far as I can see. Setting it to 100%, fixes your problem. It should be done in a stylesheet, but under is an inline solution:

<div class="container">
<div class="btn-group-vertical" style="width: 100%;">
<a href="3overview.php" class="btn btn-primary">Overview</a>
<a href="" class="btn btn-primary">Button</a>
<a href="" class="btn btn-primary">Button</a>
<a href="" class="btn btn-primary">Button</a>
<br>
<a href="" class="btn btn-warning">Button</a>
<a href="" class="btn btn-danger">Button</a>
</div>
</div>

EDIT: While this works, I'd go with Vlads answer instead. It is better than mine. And works as well. Although, you do not have to add the class to the individual buttons. Adding the class to the button group is enough. Like this:

<div class="container">
    <div class="btn-group-vertical btn-block" style="width: 100%;">
        <a href="3overview.php" class="btn btn-primary">Overview</a>
        <a href="" class="btn btn-primary">Button</a>
        <a href="" class="btn btn-primary">Button</a>
        <a href="" class="btn btn-primary">Button</a>
        <br>
        <a href="" class="btn btn-warning">Button</a>
        <a href="" class="btn btn-danger">Button</a>
    </div>
</div>
like image 75
jumps4fun Avatar answered Sep 22 '22 23:09

jumps4fun