Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
Bootstrap 5 aligning buttons in a row

I'm trying to get the buttons on my webpage to be side by side in the middle of the page, these are the 2 bootstrap 5 classes I've attempted and they aren't as I want them to look:

  1. https://gyazo.com/c23f2eade4614380aec547b11e61387a
  2. https://gyazo.com/e40a678b02c9f641f746b1cfbe83d03f

For reference, some questions will have answers with multiple buttons (up to 10: https://gyazo.com/15d810f8c0f79f23d12463db9ba50e2a), I would also like them to be equally spaced in a row, something like this: https://gyazo.com/ca1ab61aa7fef54f1cf1a099cb56a5e0

I'm not sure if this changes anything but the buttons are added using a for loop in javascript.

Any tips would be much appreciated, I've been quite stuck on this

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

I have success with class="btn-group" Exemple:

<div class="btn-group">
  <button type="button" class="btn btn-primary">Apple</button>
  <button type="button" class="btn btn-primary">Samsung</button>
  <button type="button" class="btn btn-primary">Sony</button>
</div>

View more detail in: https://www.w3schools.com/bootstrap/bootstrap_button_groups.asp

about 4 years ago · Juan Pablo Isaza Report

0

Add a element that fill have all the buttons, in your css folder, style that div with these styles:

{ 
  display:flex; align-item:center;
  justify-content: space-around;
}

If they are many buttons, let the display: flex;, to be display: inline-flex;.

about 4 years ago · Juan Pablo Isaza Report

0

You dont need any classes by default they will align themselfs in a row and we can use text-center on the container to make them centered horizontally

<script src="https://unpkg.com/@popperjs/core@2.11.0/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>


<div class="container text-center">
  <button class="btn btn-primary" type="submit">Button</button>
  <button class="btn btn-primary" type="submit">Button</button>
  <button class="btn btn-primary" type="submit">Button</button>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!