Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
I am trying to center 1 product on spotlight theme, It works on mobile but for desktop I cant find the solution.
Tried to use "maximum products to show" and put it to one but 2 is miminum.
Help is appreciated thank you
Solved! Go to the solution
This is an accepted solution.
Modify the code to center a single product: Within the loop, add a conditional statement to check if it's the first product being rendered. If it is, apply a CSS class or style that centers the product. Here's an example:
{% for product in collection.products %}
{% if forloop.index == 1 %}
<div class="centered-product">
<!-- Code for displaying the product -->
</div>
{% else %}
<div class="other-products">
<!-- Code for displaying other products -->
</div>
{% endif %}
{% endfor %}
.centered-product {
margin: 0 auto;
text-align: center;
}
This is an accepted solution.
Modify the code to center a single product: Within the loop, add a conditional statement to check if it's the first product being rendered. If it is, apply a CSS class or style that centers the product. Here's an example:
{% for product in collection.products %}
{% if forloop.index == 1 %}
<div class="centered-product">
<!-- Code for displaying the product -->
</div>
{% else %}
<div class="other-products">
<!-- Code for displaying other products -->
</div>
{% endif %}
{% endfor %}
.centered-product {
margin: 0 auto;
text-align: center;
}
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025