Jump to content

Centre product variant field on shop front page only

Go to solution Solved by tuanphan,

Recommended Posts

I have some code to reduce the size and centre the Add To Cart button and product variant field on the shop front page.  Works exactly as I'd like: https://www.adamblyth.com.au/prints

However when I click into a product to view further details, the product variant field is also centred - I want this to stay left aligned for all products.

https://www.adamblyth.com.au/prints/p/style-01-ej5na-5k3ns-n9fkm

Screenshot 2024-08-17 142741.jpg

Edited by AdamBlyth
Link to comment

It sounds like you're close to getting the layout just right! To keep the variant field centered only on the shop front page, you might need to adjust your custom code to apply specifically to that page. On Squarespace, you can typically do this by targeting only the front page elements. For product pages, ensure your code isn’t applied globally.

Link to comment
Posted (edited)

Code isn't applied globally, I've added the following code via Page Header Code Injection for 

https://www.adamblyth.com.au/prints

// Reduce size of variant dropdown & centre //
<style>
.product-variants {
  	width: 40% !important;
	margin: 0 auto;
  	text-align: center !important;
}
</style>

 

But that code is also impacting:

https://www.adamblyth.com.au/prints/p/style-01-ej5na-5k3ns-n9fkm

which is causing the variant field to also centre on that page.

Edited by AdamBlyth
Link to comment
  • Solution
18 hours ago, AdamBlyth said:

Code isn't applied globally, I've added the following code via Page Header Code Injection for 

https://www.adamblyth.com.au/prints

// Reduce size of variant dropdown & centre //
<style>
.product-variants {
  	width: 40% !important;
	margin: 0 auto;
  	text-align: center !important;
}
</style>

 

But that code is also impacting:

https://www.adamblyth.com.au/prints/p/style-01-ej5na-5k3ns-n9fkm

which is causing the variant field to also centre on that page.

Add this under your code

<style>
  .ProductItem-details .product-variants {
    margin-left: 0 !important;
}
</style>

and remove this comment text, unless it will appear on top of site when loading

image.png.c016f4700dfde52db88c20716f9c9401.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.