To align elements, you can utilize the row
and col
classes.
Here is an example with minimal CSS:
.inline {
display: inline-block;
margin: 25px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous" />
<div class="inline">
<div class="row">
<button type="button" class="btn btn-primary col">btn1</button>
</div>
<div class="row">
<button type="button" class="btn btn-primary col-6">btn2</button>
<button type="button" class="btn btn-primary col-6">btn3</button>
</div>
<div class="row">
<button type="button" class="btn btn-primary col-4">btn4</button>
<button type="button" class="btn btn-primary col-4">btn5</button>
<button type="button" class="btn btn-primary col-4">btn6</button>
</div>
</div>
Here is a duplicate of an image example:
.inline {
display: inline-block;
margin: 25px;
border: 1px solid rgba(0, 0, 0, 0.5);
border-radius: 5px;
}
.btn {
border: 1px solid rgba(0, 0, 0, 0.3) !important;
border-radius: 0 !important;
}
.row {
margin: 0 !important;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous" />
<div class="inline">
<div class="row">
<button type="button" class="btn btn-primary col">btn1</button>
</div>
<div class="row">
<button type="button" class="btn btn-primary col-6">btn2</button>
<button type="button" class="btn btn-primary col-6">btn3</button>
</div>
<div class="row">
<button type="button" class="btn btn-primary col-4">btn4</button>
<button type="button" class="btn btn-primary col-4">btn5</button>
<button type="button" class="btn btn-primary col-4">btn6</button>
</div>
</div>
Please note that I have applied important styles to override bootstrap's default styles. If you include your stylesheet after the bootstrap CSS, you may not need to use !important
.