Centering items inside the custom code block

I’ve come across this a few times when trying to implement custom code. It always left aligns.

Does anyone know what the code would look like to make the whole piece of custom code (whether it’s a Mailchimp form, “Listen on Spotify” snippet, etc.) center align?

Dear @JohnK,

Can you please add the page URL where I can see this?

Thanks!

@Suzie I can share the code (the site is confidential at this point)

This code simply sits within a “Custom Code” block. I would like to center it on the page.

<(remove this to make code work)a target=“_blank” href=“YOUR APPLE PODCASTS URL” style=“display: inline-block; background-color: #FFFFFF; background-image: url(Group 10); background-repeat: no-repeat; border: 1px solid #000000; border-radius: 5px; margin: 0 5px 5px 0; text-indent: -9000px; background-position: -230px 7px; height: 40px; width: 165px;”>Listen on Apple Podcasts

@JohnK thanks, will check and update :slight_smile:

@JohnK To do this, you would need to add a little custom styling to your text or block. If you just want the one line of text to be centered, then you could achieve this by wrapping it in a <p> tag with style="text-align:center;". For example:

<p style="text-align:center"><a target=“_blank” href=“YOUR APPLE PODCASTS URL” style=“display: inline-block; background-color: #FFFFFF; background-image: url(Group 10); background-repeat: no-repeat; border: 1px solid #000000; border-radius: 5px; margin: 0 5px 5px 0; text-indent: -9000px; background-position: -230px 7px; height: 40px; width: 165px;”>Listen on Apple Podcasts</p>

If you need to center a <div>, then you could write some CSS to center that. This is a good article that talks about how to do this: How to Horizontally Center a Div with CSS

2 Likes

This is super helpful, I think this will work. Thanks Derek!

1 Like

Dear @JohnK,

I just noticed that you have removed the <div class="w-100 text-center"> this part which is included within the custom code block when you add it.

Also noticed that @Derek helped with this :slight_smile:

Let me know if I can be of your further assistance :slight_smile:

2 Likes