A user applied custom CSS to overlay text on multi-column images but needed it to affect only the homepage, not site-wide.
Two solutions were provided:
Section-specific targeting: Use the unique section template ID (e.g., .section-template--23195023278374__multicolumn_WQz7RE-padding) as a CSS selector to limit styling to that specific multi-column section. This approach also included code optimization for better tablet responsiveness.
JavaScript URL detection: Add a script to theme.liquid that checks if the current page is the homepage (/) and dynamically injects the CSS only when true.
Current status: The original poster confirmed the solution worked. A follow-up question emerged about mobile responsiveness—specifically requesting a background for buttons (currently transparent) and tighter spacing between title and body text on mobile devices. This mobile styling issue remains unresolved.
Summarized with AI on October 30.
AI used: claude-sonnet-4-5-20250929.
There is 2 ways, add the if template or use the section template i.d. If you use the I.D it will call only on the multicolumn section. Even you add another multi column on the homepage. Check this one,.
You can use JavaScript to apply the CSS only on the homepage, you need to add a script that checks the URL of the page. Then, apply the CSS changes when the page only is the homepage.
Here’s how to do it:
Step 1: Go to Admin → Online store → Theme > Edit code:
This works great on desktop, but it doesn’t transfer to mobile. Is there a way to have the button in the photo to have a background because at the moment it is transparent. Also is there a way to make the title and the body text closer together? What would I add to the code?