Hello I want the text and button I have to be on a single line instead of underneath each other. First I did this with
<div class="btn-group" role="group" aria-label="Basic example"><p>Document2.pdf</p><button type="button" class="btn btn-primary">Download</button></div><br>
But this put the button and the text right next to each other with no spacing. So instead of btn-group I used btn-toolbar but this put the items underneath each other.
<div class="btn-toolbar" role="group" aria-label="Basic example"><p>Document1.pdf</p><br><button type="button" class="btn btn-primary">Download</button></div><br>
I tried adding flex-wrap: nowrap but this didn't work. Does anyone know how to fix this problem and properly align them?
Simply add margin-right
.
OPTION 1 (recommended): Use the Bootstrap class (e.g., me-3
)
See the snippet below.
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<div class="btn-group" role="group" aria-label="Basic example">
<p class="me-3">Document2.pdf</p><button type="button" class="btn btn-primary">Download</button>
</div>
OPTION 2: Use CSS
See the snippet below.
p {
margin-right: 16px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<div class="btn-group" role="group" aria-label="Basic example">
<p>Document2.pdf</p><button type="button" class="btn btn-primary">Download</button>
</div>