Help centering a submit button

Help centering a submit button
0

Hi FCC,

New to coding and I’m trying to create any email sign up form the is here.

I can’t get the submit button to center, I’ve tried position: relative, text-align: center. Could anyone point me in the right direction of what I’m doing wrong with my CSS?

Thanks,

Pete

Hi Pete,

The easiest way would let the browser figure out which one is the actual center based on the element width, and you can achieve that easily with flexbox.

On #button-position simply add:

display: flex;
justify-content: center;

Then my personal suggestion would be to get rid of that fixed width you have on both #button-position and #button-style and let it as big as its content.
Use then padding on the button to play with spaces :slight_smile:

Hope this helps.

1 Like

@Marmiz very helpful thanks for the advice.