I can’t center my buttons on my website. My code is below:
.buttonHolder {
text-align: center;
display: flex;
}
<div class="buttonHolder">
<form action="#sweater">
<input type="submit" value="Sweater" />
</form>
<form action="#pants">
<input type="submit" value="Pants" />
</form>
<form action="#shirt">
<input type="submit" value="Shirt" />
</form>
<form action="#suit">
<input type="submit" value="Suit" />
</form>
</div>
The website looks like this, not how I intended:
I want them to be centered.
3
Answers
You are just missing one css property. Add
justify-content: center
tobuttonHolder
and you are done.Below is working example of same.
2 Flexbox properties to center:
1 Grid property:
Aside from the above, you can apply internal css to center button