Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

CSS grid Image Gallery Customization In Dawn Theme

Solved

CSS grid Image Gallery Customization In Dawn Theme

MuneebJoiya
Shopify Partner
14 0 1

I have a CSS grid made by me and I want to add a button, rich text and Heading on the grid images. But the buttons are showing just beneath the grid.

{% schema %}
{
  "name": "Grid layout",
  "settings": [],
  "blocks": [
    {
      "name": "Collage Image",
      "type": "collage_image",
      "settings": [
        {
          "type": "image_picker",
          "id": "collage_image",
          "label": "Collage Image"
        },
        {
          "type": "checkbox",
          "id": "show_button",
          "label": "Show Button"
        },
        {
          "type": "text",
          "id": "button_text",
          "label": "Button Text",
          "default": "Learn More"
        },
        {
          "type": "url",
          "id": "button_link",
          "label": "Button Link"
        },
        {
          "type": "select",
          "id": "button_position",
          "label": "Button Position",
          "options": [
            {
              "value": "top-left",
              "label": "Top Left"
            },
            {
              "value": "top-right",
              "label": "Top Right"
            },
            {
              "value": "bottom-left",
              "label": "Bottom Left"
            },
            {
              "value": "bottom-right",
              "label": "Bottom Right"
            }
          ]
        },
        {
          "type": "text",
          "id": "heading",
          "label": "Heading"
        },
        {
          "type": "richtext",
          "id": "rich_text",
          "label": "Rich Text"
        }
      ]
    }
  ],
  "presets": [
    {
      "name": "Grid Layout"
    }
  ]
}
{% endschema %}

<style>
.customCollage {
  width: 100%;
  height: auto;
  display: grid;
  grid-column-gap: 15px;
  padding: 50px;
  grid-template-columns: repeat(2, 46vw);
  grid-template-rows: repeat(2, 37vw);
  grid-template-areas:
    "a b"
    "a c";
  justify-content: center;
}

.collageImageContainer {
  position: relative;
  overflow: hidden; /* Hide any overflow from the image */
}

.collageImage {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.imageOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  box-sizing: border-box;
}

.customButton {
  display: inline-block;
  padding: 10px 20px;
  background-color: #007bff;
  color: #ffffff;
  text-decoration: none;
  border-radius: 5px;
}

.richText {
  color: #ffffff;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 10px;
  border-radius: 5px;
  max-width: 70%;
}
</style>

<div class="customCollage">
  {% for block in section.blocks %}
      <div class="collageImageContainer">
    <div class="customBlock" style="grid-area:
      {% case forloop.index %}
        {% when 1 %} a
        {% when 2 %} b
        {% when 3 %} c
      {% endcase %};">
        <img class="collageImage" src="{{ block.settings.collage_image | img_url: 'large' }}" loading="lazy" width="100%" height="100%">
        <h2>{{ block.settings.heading }}</h2>
        <div class="richText">{{ block.settings.rich_text }}</div>
        {% if block.settings.show_button %}
          <a href="{{ block.settings.button_link }}" class="customButton">{{ block.settings.button_text }}</a>
        {% endif %}
      </div>
    </div>
  {% endfor %}
</div>

 I want the grid to be like this

MuneebJoiya_0-1692968653134.png

 But mine is Like this I only want the text and button to show on top the image not beneath. And when I show the button it also takes grid area I don't want that type of layout

 

MuneebUrRehman
Accepted Solution (1)
Moeed
Shopify Partner
7764 2082 2567

This is an accepted solution.

Hey @MuneebJoiya 

 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file

4) Add the following code in the bottom of the file above </body> tag

<style>
.customButton {
    z-index: 1 !important;
    position: inherit;
    bottom: 150px;
    left: 630px;
}
</style>

RESULT:

Moeed_0-1692971235943.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


View solution in original post

Replies 7 (7)

Moeed
Shopify Partner
7764 2082 2567

Hey @MuneebJoiya 

 

Could you please provide your Store URL and, if applicable, the Password too? Your cooperation is greatly appreciated!

 

Best Regards,
Moeed

 

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


MuneebJoiya
Shopify Partner
14 0 1

https://theese-ca.myshopify.com/

Password : stiesk

 

MuneebUrRehman
Moeed
Shopify Partner
7764 2082 2567

Hey @MuneebJoiya 

 

I'm unable to locate any button on the website, can you please add the buttons first?

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


MuneebJoiya
Shopify Partner
14 0 1

Please check again I have enabled the button

MuneebUrRehman
Moeed
Shopify Partner
7764 2082 2567

This is an accepted solution.

Hey @MuneebJoiya 

 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file

4) Add the following code in the bottom of the file above </body> tag

<style>
.customButton {
    z-index: 1 !important;
    position: inherit;
    bottom: 150px;
    left: 630px;
}
</style>

RESULT:

Moeed_0-1692971235943.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


MuneebJoiya
Shopify Partner
14 0 1

MuneebJoiya_0-1692971408134.png

But Text Remain there I also want text there

 

MuneebUrRehman
MuneebJoiya
Shopify Partner
14 0 1

MuneebJoiya_1-1692971510131.png

And also the right grid-area a image to be fully matched like the screenshot I provided in My first Question

MuneebUrRehman