Lesson 38 of 39
In Progress

Button Group Button

Bootstrap button group groups a series of buttons together in a single line.

To create a button groups, wrap a series of buttons in a <div> element and apply the class .btn-group on it.

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style type="text/css">
    .bs-button{
      margin: 20px;
    }
</style>
</head>
<body>
<div class="bs-button">
    <div class="btn-group">
        <button type="button" class="btn btn-info">Left</button>
        <button type="button" class="btn btn-primary">Middle</button>
        <button type="button" class="btn btn-success">Right</button>
    </div>
</div>
</body>
</html>

Output:

KodNest bt36 1

Vertical button groups

To create vertical button groups, use the .btn-group-vertical class.

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style type="text/css">
    .bs-button{
      margin: 20px;
    }
</style>
</head>
<body>
<div class="bs-button">
    <div class="btn-group-vertical">
        <button type="button" class="btn btn-info">Top</button>
        <button type="button" class="btn btn-primary">Middle</button>
        <button type="button" class="btn btn-success">Bottom</button>
    </div>
</div>
</body>
</html>

Output:

KodNest bt37

Button Toolbar

We can combine button groups together to create button toolbar.

To create button toolbar, wrap button groups in a <div> element and apply the class .btn-toolbar on it.

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style type="text/css">
    .bs-button{
      margin: 20px;
    }
</style>
</head>
<body>
<div class="bs-button">
    <div class="btn-toolbar">
        <div class="btn-group">
            <button type="button" class="btn btn-info">1</button>
            <button type="button" class="btn btn-info">2</button>
            <button type="button" class="btn btn-info">3</button>
            <button type="button" class="btn btn-info">4</button>
        </div>
        <div class="btn-group">
            <button type="button" class="btn btn-info">5</button>
            <button type="button" class="btn btn-info">6</button>
            <button type="button" class="btn btn-info">7</button>
        </div>
        <div class="btn-group">
            <button type="button" class="btn btn-info">8</button>
            <button type="button" class="btn btn-info">9</button>
        </div>
        <div class="btn-group">
            <button type="button" class="btn btn-info">10</button>
        </div>
    </div>
</div>
</body>
</html>

Output:

KodNest bt38

Height of Button Groups

We can apply relative sizing classes like .btn-group-lg, .btn-group-sm or .btn-group-xs on button groups to create larger or smaller button groups.

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style type="text/css">
    .bs-button{
      margin: 20px;
    }
</style>
</head>
<body>
<div class="bs-button">
    <div class="btn-toolbar">
        <div class="btn-group btn-group-lg">
            <button type="button" class="btn btn-info">Left</button>
            <button type="button" class="btn btn-info">Middle</button>
            <button type="button" class="btn btn-info">Right</button>
        </div>
    </div>
    <br>
    <div class="btn-toolbar">
        <div class="btn-group">
            <button type="button" class="btn btn-info">Left</button>
            <button type="button" class="btn btn-info">Middle</button>
            <button type="button" class="btn btn-info">Right</button>
        </div>
    </div>
    <br>
    <div class="btn-toolbar">
        <div class="btn-group btn-group-sm">
            <button type="button" class="btn btn-info">Left</button>
            <button type="button" class="btn btn-info">Middle</button>
            <button type="button" class="btn btn-info">Right</button>
        </div>
    </div>
    <br>
    <div class="btn-toolbar">
        <div class="btn-group btn-group-xs">
            <button type="button" class="btn btn-info">Left</button>
            <button type="button" class="btn btn-info">Middle</button>
            <button type="button" class="btn btn-info">Right</button>
        </div>
    </div>
</div>
</body>
</html>

Output:

KodNest bt39

Justified Button in Groups

We can make a group of buttons stretch at the same size to span the entire width of its parent by applying an extra class .btn-group-justified to the .btn-group base class.

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style type="text/css">
    .bs-button{
      margin: 20px;
    }
</style>
</head>
<body>
<div class="bs-button">
    <div class="btn-group btn-group-justified">
        <a href="#" class="btn btn-info">Left</a>
        <a href="#" class="btn btn-info">Middle</a>
        <a href="#" class="btn btn-info">Right</a>
    </div>
</div>
</body>
</html>
KodNest bt40
KodNest Training New Batch is starting on 02nd November 2020. Attend one week free demo classes.Register Now

New Report

Close