How to add margin between product image cover and header/announcement bar while scrolling?

Hello experts!

Help me solve this case. I want to add margin between product image cover and header/announcement bar while I scroll the product description. Note that the image is sticky now in general. I just want to be simetric with a bit of margin above the image while scrolling down. Please find attached preview from now.

URL: https://www.elysiumreads.com/

2 Likes

Hi @starscream911
To add space between the top bar and image add the below CSS to base.css

.media>*:not(.zoom):not(.deferred-media__poster-button), .media model-viewer {
    top: 25px !important;
}

Hi @starscream911 ,

Step 1: Go to Shopify Admin β†’ Online Store ->Theme β†’ Edit code

Step 2: Search file theme.liquid

Step 3: Insert this code above tag:


Here is result:

Hope this can help you,

If our suggestions are useful, please let us know by giving it a like or marking it as a solution. Thank you :heart_eyes:

1 Like
  • Here is the solution for you @starscream911
  • Please follow these steps:

  • Then find the theme.liquid file.
  • Then add the following code at the before tag and press β€˜Save’ to save it.

  • Here is the result you will achieve:

  • Please press β€˜Like’ and mark it as β€˜Solution’ if you find it helpful. Thank you.
1 Like

Hi Starscream, love the name, reminds me of Transformers!

Anyway, add this Custom CSS to your section.

@media screen and (min-width: 750px) {
  .product__column-sticky {
    padding-top: 16px;
  }
}

Adjust the number to your preference and you should have a result like this:

Hope this helped!

Hello!

Yes, the idea is from Transformers! :wink:

Tell me!

Works perfectly!

Thank you, my friend!

Hello!

Thanks for reaching out. This code doesn’t work properly. It eats the top area of all my product images.

Hello!

Works perfectly!

Thank you!

1 Like