Elevate Your Shopify Store: Adding a Dynamic 3D Float Effect to Product Images (Ritual Theme Guide)
Hey everyone! As a Shopify migration expert and someone who spends a lot of time in the community forums, I often see store owners looking for ways to make their products truly pop. One recent discussion caught my eye, and it's a fantastic example of how collective problem-solving can lead to elegant solutions. Our friend ABdev1 was trying to add an 'always-on' 3D float effect to product images in their Featured Collection sections, specifically on the Ritual theme. They'd tried everything, even AI tools like Perplexity, but were hitting a wall. Sound familiar? Let's dive into what we learned together.
ABdev1's goal was to give these product images a subtle, continuous 3D float, making them stand out on the page, as you can see from their original post:
The Challenge with Custom CSS
ABdev1's initial hurdle, and one many of you might encounter, was trying to inject complex CSS, specifically the @keyframes rule, directly into the Custom CSS field of a section. As Mateo-Penida and Maximus3 soon discovered, and as tim_tairli brilliantly clarified, Shopify's Custom CSS fields can be quite 'picky' and have restrictions. They simply don't accept @keyframes definitions directly. This is why ABdev1 was getting errors and seeing no effect, even when the CSS looked perfectly valid on paper or in a browser's console.
Community Brainstorming: Early Attempts and Key Learnings
Mateo-Penida jumped in first with some solid suggestions, initially testing a dynamic script in the browser console which worked perfectly. This included a cool 3D rotation along with the float. The key selectors for the product images were identified as img.product-media__image, and for the featured collection section, it was .section-resource-list. However, transferring this directly to the theme editor's Custom CSS field proved problematic due to those @keyframes restrictions.
ABdev1 even shared screenshots of where they were attempting to inject the code, illustrating the challenge of getting the CSS to take effect:
They also meticulously inspected the elements, confirming the key selector was img.product-media__image, as shown here:
Maximus3 then offered a more direct approach: putting the entire CSS, including @keyframes, into the theme's main CSS file, typically Assets/base.css. This can work, but Maximus3 rightly pointed out a big caveat: if you don't narrow it down, this effect would apply to all product card images across your entire store. To avoid that, you'd need to target specific section IDs, like #shopify-section-template--20099090317391__product_list_NgyDci. While effective for specific sections, hardcoding these IDs can be a bit rigid and might require updates if you rearrange your sections.
The Elegant Solution: Splitting Your CSS for Success
This is where tim_tairli's insights really shone through, providing the most flexible and 'Shopify-friendly' solution. The trick is to understand where Shopify allows certain types of CSS. Since the Custom CSS field in sections doesn't like @keyframes, we need to put that part somewhere else. The brilliant workaround? The 'Custom Liquid' section!
By splitting your CSS, you get the best of both worlds: global definition for the animation logic (@keyframes) and local application for the animation itself (animation: float3d...). This approach avoids directly editing core theme files like base.css or layouts/theme.liquid, which is a huge win for theme update safety and overall maintainability. Plus, it lets you apply the effect only to the sections you want, just like ABdev1 intended.
Step-by-Step: Adding Your 3D Float Effect
Ready to give your product images that subtle, eye-catching float? Here's how to implement the community-tested solution:
Step 1: Always Duplicate Your Theme First!
Before making any code changes, always, always, always duplicate your theme. This is your safety net! Go to Online Store → Themes, find your current theme, click the three dots, and select Duplicate.
Step 2: Define Your @keyframes Animation Using Custom Liquid
This is where we get around the Custom CSS field's limitations. We'll add a new section that can handle the @keyframes rule.
- Go to Online Store → Themes, click Customize on your duplicated theme.
- Scroll down to your Footer group (or any other general area where you won't visually interfere with content).
- Click Add section and choose Custom Liquid.
- Paste the following code into the Custom Liquid field:
This code defines ourfloat3danimation. TheJust remember to replace the simpler@keyframesyou used in Step 2 with this more complex version if you want the tilt.
This clever split-CSS method is a prime example of how understanding Shopify's editor nuances can unlock powerful customization possibilities. It allows you to add dynamic flair to your store without the headaches of direct theme file edits or the broad strokes of global CSS changes. Big thanks to ABdev1 for kicking off the discussion and to Mateo-Penida, Maximus3, and especially tim_tairli for guiding us to this elegant solution!



