Center a button? - Post ID 301307

User 515049 Photo


Registered User
35 posts

If I have a button in a container, and that container is in a row - how would I center the button?

By default it's on the left - can't seem to find a way to center it...probably something obvious I'm missing....

Thanks!
User 122279 Photo


Senior Advisor
14,450 posts
Online Now

If the button has display: block, then give it an auto margin right and left.
If the button has display: inline-block, then give the container display: flex, and for the button justify-content: center.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 515049 Photo


Registered User
35 posts

I guess that's my issue - I can't find what your suggesting - I don't see the "display" options, other than a checkbox that allows you to select "None". (see attached).

I did try the component "three color button" and that is centered - but it still bothers me why I can't get a normal button to be centered.


UPDATE - I did find that under "dimensions" I can use "float:center" - to center it - not sure if that's the right way or not.
Attachments:
User 122279 Photo


Senior Advisor
14,450 posts
Online Now

Hi Dave,

At first, I didn't notice that your question was about the Email Designer, I mistook it for being about Site Designer. So my reply was wrong, sorry.

I have now installed the latest version of Email Designer. I hadn't used it for some 6-7 years.

Yes, the 'float: center' seems to be the one to use. I was a bit perplexed when I saw that option because there actually is no such thing as 'float center' in CSS. You won't find it outside the Email Designer, or outside CC.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 515049 Photo


Registered User
35 posts

Thanks - yes, I too was very confused to see that option - but it worked - lol -

Thanks again.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.