Center product collection - Horizon Theme

Hello

I’ve been having trouble for a while now getting my collection centered here on my home page. I have tried a lot of code in base.css but none of it works. I hope someone can help me solve this problem.

Website: www.TruthTrust.dk

code: CAMO1309

here are some pics of what it looks like:

Hi @AdamT06

In your Shopify Admin go to online store > themes > actions > edit code
Find Asset > base.css and paste this at the bottow of the file:

.resource-list--grid {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: center !important;
  gap: 24px;
}

.resource-list--grid .resource-list__item {
  width: calc(33.33% - 24px);
}

.resource-list--grid .resource-list__item:only-child {
  width: 33%;
}

.resource-list--grid .resource-list__item:nth-last-child(2):first-child,
.resource-list--grid .resource-list__item:nth-last-child(2):first-child + .resource-list__item {
  width: 33%;
}

Best regards,
Devcoder :laptop:

Hi @AdamT06

Thank you for your response. It’s good to know that it’s worked for you. Kindly feel free to get back to me if you need any further assistance. If helpful, please like all posts. :white_check_mark:

Best regards,
Devcoder :laptop:

i Just noticed that after putting the Code into my base.css, it has messed up my home page on the iphone view. Do you know what has caused this. It seems like it duplicates and makes the collection grid smaller.

Before:

After:

Hi @AdamT06

Please refresh once and check again. It’s working properly from my side.

it dosent work on mine. I just checked on my mobile phone and it dosent work for me. Any idea what caused this?

you can check agian it dosent work on phone veiw

Hey @AdamT06

I have checked your website in every mobile view and I don’t see that problem occurring anywhere in your site, not sure why it’s happening on your end but I can suggest you something and maybe that would fix it.

Remove the previous code which you added and add this updated code. This code will only work for desktop so nothing breaks on mobile.

@media screen and (min-width: 768px) {
.resource-list--grid {
  display: flex !important;
  flex-wrap: wrap;
  justify-content: center !important;
  gap: 24px;
}

.resource-list--grid .resource-list__item {
  width: calc(33.33% - 24px);
}

.resource-list--grid .resource-list__item:only-child {
  width: 33%;
}

.resource-list--grid .resource-list__item:nth-last-child(2):first-child,
.resource-list--grid .resource-list__item:nth-last-child(2):first-child + .resource-list__item {
  width: 33%;
}
}

Hope that helps! If it did, a Like and Marking it as Solution goes a long way and helps others find the fix faster too.

Best,
Moeed

Hi @AdamT06,

Go to Online store > edit code > base.css > paste this code

.box-grid {

    display: flex !important;

    flex-direction: row !important;

    flex-wrap: wrap !important;

    justify-content: center !important; 

    align-items: stretch !important;

    gap: 30px !important;

    margin: 40px auto 0 auto !important;

    width: 100% !important;

    max-width: 1200px !important;

    padding: 0 !important;

}





.box-grid .product-card {

    display: flex !important;

    flex-direction: column !important;

    flex: 0 0 calc(25% - 23px) !important;

    max-width: calc(25% - 23px) !important;

    min-width: 250px !important; 

    margin: 0 !important;

    box-sizing: border-box !important;

}






@media screen and (max-width: 749px) {

    .box-grid .product-card {

        flex: 0 0 calc(50% - 15px) !important; 

        max-width: calc(50% - 15px) !important;

    }

}

Save