How to Create a Page Template with Smaller Margins

Solved

How to Create a Page Template with Smaller Margins

claribelskincar
Tourist
7 0 3

I'm trying to create a landing page with images, using the normal Page format, but when I include my images, there is a gigantic left and right margin, making the page look odd.  Is there a some advice on how I could create a template with very minimal margins?

 

Is that the route to take?  This is the page in question: https://claribelskincare.com/pages/antioxidant-skin-serum

 

Accepted Solution (1)

Laza_Binaery
Shopify Partner
399 75 115

This is an accepted solution.

Hi @claribelskincar 

 

Welcome to the community.

 

If you are OK with editing some code, then the process is not so bad. 

  1. In your Code view, under Templates create a new template named, for example," page.wide.json"
  2. There copy following code 
{
  "sections": {
    "main-wide": {
      "type": "main-page- wide",
      "settings": {
        "padding_top": 28,
        "padding_bottom": 28
      }
    }
  },
  "order": [
    "main-wide"
  ]
}​
  • Next, in sections, create a new section " main-page-wide.liquid" : 
{{ 'section-main-page.css' | asset_url | stylesheet_tag }}

{%- style -%}
  .section-{{ section.id }}-padding {
    padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
    padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
  }

  @media screen and (min-width: 750px) {
    .section-{{ section.id }}-padding {
      padding-top: {{ section.settings.padding_top }}px;
      padding-bottom: {{ section.settings.padding_bottom }}px;
    }
  }
{%- endstyle -%}

<div class="page-width section-{{ section.id }}-padding">
  <h1 class="main-page-title page-title h0{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--fade-in{% endif %}">
    {{ page.title | escape }}
  </h1>
  <div class="rte{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}">
    {{ page.content }}
  </div>
</div>

{% schema %}
{
  "name": "t:sections.main-page.name",
  "tag": "section",
  "class": "section",
  "settings": [
    {
      "type": "header",
      "content": "t:sections.all.padding.section_padding_heading"
    },
    {
      "type": "range",
      "id": "padding_top",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_top",
      "default": 36
    },
    {
      "type": "range",
      "id": "padding_bottom",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_bottom",
      "default": 36
    }
  ]
}
{% endschema %}​
  •  Then in Pages, change page template for the page you want
  • It should be better.

I removed just "page-width--narrow" class so if you want all pages to be regular page width, then you can just make change in the section main-page

https://github.com/Shopify/dawn/blob/main/sections/main-page.liquid#L17, and it will fix all pages. 

 

Try it out, backup the theme first, or create a copy.

Kind regards
Laza
www.binaery.com

View solution in original post

Replies 6 (6)

Laza_Binaery
Shopify Partner
399 75 115

This is an accepted solution.

Hi @claribelskincar 

 

Welcome to the community.

 

If you are OK with editing some code, then the process is not so bad. 

  1. In your Code view, under Templates create a new template named, for example," page.wide.json"
  2. There copy following code 
{
  "sections": {
    "main-wide": {
      "type": "main-page- wide",
      "settings": {
        "padding_top": 28,
        "padding_bottom": 28
      }
    }
  },
  "order": [
    "main-wide"
  ]
}​
  • Next, in sections, create a new section " main-page-wide.liquid" : 
{{ 'section-main-page.css' | asset_url | stylesheet_tag }}

{%- style -%}
  .section-{{ section.id }}-padding {
    padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
    padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
  }

  @media screen and (min-width: 750px) {
    .section-{{ section.id }}-padding {
      padding-top: {{ section.settings.padding_top }}px;
      padding-bottom: {{ section.settings.padding_bottom }}px;
    }
  }
{%- endstyle -%}

<div class="page-width section-{{ section.id }}-padding">
  <h1 class="main-page-title page-title h0{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--fade-in{% endif %}">
    {{ page.title | escape }}
  </h1>
  <div class="rte{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}">
    {{ page.content }}
  </div>
</div>

{% schema %}
{
  "name": "t:sections.main-page.name",
  "tag": "section",
  "class": "section",
  "settings": [
    {
      "type": "header",
      "content": "t:sections.all.padding.section_padding_heading"
    },
    {
      "type": "range",
      "id": "padding_top",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_top",
      "default": 36
    },
    {
      "type": "range",
      "id": "padding_bottom",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_bottom",
      "default": 36
    }
  ]
}
{% endschema %}​
  •  Then in Pages, change page template for the page you want
  • It should be better.

I removed just "page-width--narrow" class so if you want all pages to be regular page width, then you can just make change in the section main-page

https://github.com/Shopify/dawn/blob/main/sections/main-page.liquid#L17, and it will fix all pages. 

 

Try it out, backup the theme first, or create a copy.

Kind regards
Laza
www.binaery.com
claribelskincar
Tourist
7 0 3

Hi Laza,

 

I'm receiving a save error message when copying in the first part of the code you've recommended, see screenshot attached.  Can you please advise?Screenshot (436).png

claribelskincar
Tourist
7 0 3

I fixed it, thank you so much.

Laza_Binaery
Shopify Partner
399 75 115

Hi @claribelskincar

 

Glad you sorted it out, I missed that space in ""type": "main-page- wide", line. 

 

 

Kind regards
Laza
www.binaery.com
claribelskincar
Tourist
7 0 3

You saved the day! 👍

devcoders
Shopify Partner
1288 150 362

Hello @claribelskincar 

 

Go to Online Store, then Theme, and select Edit Code.
Search for assets/base.css Add the provided code at the end of the file.

 

.page-width--narrow {
max-width: 160rem;
padding: 0 5rem;
}

 

devcoders_0-1743046475664.png

 

 

Shopify Developer: Helping eCommerce Stores
If you need assistance with your store, feel free to contact us at devcodersp@gmail.com
WhatsApp No: +91 8516919310 If my assistance was helpful, please consider liking and accepting the solution. Thank you!