I have 4 buttons that I want to be centered and have like the same amount of margin in between them so it’s gonna look something like this:
|–button–button–button–button–|
What’s the best way to do this? Because i am giving the margin my self now but sometimes it yeets one of the button’s underneath other button’s
<div id="">
<button id="buttons" type="button" class="btn btn-secondary">Print Label</button>
<button id="buttons" type="button" class="btn btn-secondary">Label Wijzigen</button>
<button id="buttons" type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#eanScan">Scan</button>
<button id="buttons" type="button" class="btn btn-secondary">Verzenden</button>
</div>
and this is my css
#buttons {
margin: 22px;
margin-top: 0px !important;
height: 175px;
width: 175px;
text-align: center;
}
```
3
Answers
there are several ways,
one way is to target all buttons but not the last one
another way is to target the button if after another button
Try this:
Using the class
d-flex
anjustify-content-around
You can have evenly big space around your buttons in the parent div:For more flexbox items LINK