-
AmDev1
Hi,
My product pages are made up of code snippets and elements. I have limited control over the product image though.
I am aiming to make the iamge sticky but only as far as the container on the right (see here: https://mowgli-adventures.com/product/270ah-12v-lifepo4-deep-cycle-gc3-battery/)
I added this code: woocommerce div.product div.images.woocommerce-product-gallery {
position: sticky;
top: 0;
} and it did make the image sticky but all the way to the bottom of the page. How can get it to stop being sticky at the right place?
Kind regards -
David
Hi there,
try this CSS:
@media(min-width: 1024px) { .woocommerce.single div.product { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; } .woocommerce.single div.product > div { width: 100% !important; grid-column: 1 / -1; } .woocommerce.single div.product > .woocommerce-product-gallery { grid-column: 1; } .woocommerce.single div.product > .entry-summary { grid-column: 2; } .woocommerce-product-gallery__wrapper { position: sticky; top: 0; } }
It sets the page up using CSS grid, so you the product-gallery and the summary are equal heigh columns, allowing you to then sticky the gallery_wrapper inside.
Note I set the
@nedia
to 1024px so it kicks in only on larger screens. -
AmDev1
Perfect – thank you!
-
David
You’re welcome
- You must be logged in to reply to this topic.