Center Related Products - Product Page

Center Related Products - Product Page

ellacoker
Shopify Partner
283 1 72

Hello!

I have just realised that my "related products" at the bottom of my product page are not centered. Please see screenshot for reference. Is someone able to please give me the code for this? I want the "you may also like" text to come in line with the images please.

 

For the mobile version of this same section, I would like less padding to the left and right, and the titles of each product to be centered on the image. 

Screenshot 2025-05-02 at 14.53.13.png

Thank you very much! Ella

 

URL: https://www.livwithin.com.au/products/soft-weave-mat-sun

 

Screenshot 2025-05-02 at 14.50.40.png

Replies 5 (5)

Guleria
Shopify Partner
4146 809 1164

Hello @ellacoker ,

 

Follow these steps:

1. Go to Online Store -> Theme -> Edit code

2. Open your Assets > base.css file and paste the following code at the bottom:

h2.related-products__heading.inline-richtext.h2 {
    text-align: center;
}
@media screen and (max-width: 767px) {
product-recommendations.related-products.page-width {
    padding: 0 0px !important;
}
}

 

Regards
Naveen

- Custom themes, UI/UX design, ongoing maintenance & support.
- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder

tapan_sain
Shopify Partner
24 1 6

Hello @ellacoker 

Please add the code below to your CSS file(base.css). 

// to add space at the top of the section
.related-products{
    margin-top: 50px;
}


// to center the heading
.related-products .related-products__heading{
   text-align: center;
}

// to center the product grid
.related-products .grid.product-grid{
   display: flex;
   flex-flow: row wrap;
   justify-content: center;
}

 

Now you will add this code after the recommendation section will look like this(Attached screenshot). 
Screenshot from 2025-05-02 11-14-18.png

Made4uo-Ribe
Shopify Partner
10184 2417 3060

Hi @ellacoker 

Try this one. 

  1. From your Shopify admin dashboard, click on "Online Store" and then "Themes".
  2. Find the theme that you want to edit and click on "Actions" and then "Edit code".
  3. In the "Assets" folder, click on "base.css, style.css or theme.css" file, depending on which file your theme uses to store its CSS styles. At the bottom of the file, add the following CSS code:
h2.related-products__heading.inline-richtext.h2 {
    text-align: center !important;
}
@media only screen and (max-width: 749px){
product-recommendations.related-products.page-width {
    padding: 0 20px !important;
}
}
  • And Save.
  • Result:
  • Made4uoRibe_0-1746180425647.pngMade4uoRibe_1-1746180435970.png

     

 

Please don't forget to Like and Mark Solution to the post that helped you. Thanks!

If this fixed your issue, Likes and Accept as Solution are highly appreciated. Coffee tips fuel my dedication.
Get experienced Shopify developers at affordable rates—visit Made4Uo.com for a quick quote!
Need THEME UPDATES but have custom codes? No worries, for an affordable price.
ellacoker
Shopify Partner
283 1 72

Hello, The mobile worked! however, there is still too much padding to the right on desktop. Can I add something to that code to fix this?

Thanks!

Ella.

URL: https://www.livwithin.com.au/products/soft-weave-mat-sand

Screenshot 2025-05-03 at 09.38.51.png

 

WebDeskSolution
Shopify Partner
231 52 61

Hello @ellacoker 

 

Please follow the steps below after logging into the Shopify admin:

 

  • Go to your Shopify Admin panel.
  • Click on Online Store > Themes.

 

 

  • Find the live theme and then click Actions > Edit code.
  • Search base.css
  • Insert the provided CSS code at the end of the file and save the changes.

 

.related-products .related-products__heading
{
    padding: 0 10px;
}
@media screen and (max-width: 479px)
{
product-recommendations.related-products.page-width
{
    padding: 0 15px !important;
}
product-recommendations.related-products .card .card__heading .full-unstyled-link
{
    text-align: center;
}
}

 

Please hit Like and Mark it as a Solution if you find our reply helpful.

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Shopify Partner | Shopify Development Agency | Call: 877.536.3789


Canada: 150 King St W. STE 200, Toronto, ON M5H 1J9

 | USA: 98 Cutter Mill Rd. STE 466, Great Neck, NY 11021