How to add padding to select pages (like blog posts)

Hello,

I’m looking to add padding on the left and right side of a blog post on the Creator theme (or any theme) so it can narrow the body and text.

I see that there’s already been a solution to this answered by @GemPages here: https://community.shopify.com/post/1882010

But I’m not sure where to utilize or put this code:


By the way, does the padding in the above code work for left and right margins only? Or will it change all margins at once. It seems like one can already change top/bottom margins in the Shopify theme customization screen.

Would appreciate any help with this!

hi @huqsy

step 01:

  1. Go to your Store > Theme > click to edit code.
  2. find this file “theme.liquid” and open.

step 02:

  1. Paste the code at end of the file.

Thank you,

I have a quick follow up question:

Will this change the left/right padding for both mobile and desktop? I’m wondering how to do that separately.

you need to use meadia query if you know it will possible for mobile and dasktop changes separately.

Hi @huqsy

You can try this code by following these steps:

Go to Online store => themes => actions => edit code and add this code on file theme.liquid before tag


Hope this answer helps.

Best regards,

Victor | PageFly

I appreciate it Victor, thank you!

And does this only work for blog posts?

Also do you happen to know a way to change the h1, h2, h3, body, etc. font sizes within blog posts only as well? I’m trying to keep it separate from other page stylings.

If not, no worries! Really appreciate the help.

You can add this code on the file theme.liquid to make css only page Blog

{% if page.url contains 'blog' %}

{% endif %}