Shopify themes, liquid, logos, and UX
On a product page we display a row of icons, looking like this:
It's basically a list of <IMG> tags (wrapped in a conditional loop, which I leave out here to stay focussed).
<img alt="Suited for Afro Hair" src="{{ 'feat-afro.svg' | asset_url }}" style="max-height: 70px" />
<img alt="Suited for all hair types" src="{{ 'feat-all-hair-types.svg' | asset_url }}" style="max-height: 70px" />
To handle the styling, we use this CSS (without css, the icons do not appear next to each other, but each on a new line)
.feature-icons {
display: flex;
flex-wrap: wrap;
justify-content: center;
column-gap: 0.5em;
row-gap: 10px;
}
It's relatively easy to make the icon interactive, in this case: link the to a filtered collection page with all similar products.
<a href="/collections/hair-care?filter.p.m.custom.hair_types=Afro">
<img alt="Suited for all hair types" src="{{ 'feat-afro.svg' | asset_url }}" style="max-height: 70px" />
</a>
However, as soon as we add the CSS, the icons do not appear anymore.
Yet, if we replace the <img> with a simple text tag, it works again.
So something in the CSS doesn't work well with <a> & <img> tags combined.
Any suggestions?
Solved! Go to the solution
This is an accepted solution.
The flexbox on the parent element is now just flexing the anchor elements, as the image elements are now inside those. You're also setting max height on the image elements but not height, so the images will still be there but may just have zero height. Try adding the following to your style:
.feature-icons a img{
height: 70px;
width: auto;
}
It might also help to see the actual page in case there are other styles overruling what you have here - stand along snippets can be a bit misleading.
This is an accepted solution.
The flexbox on the parent element is now just flexing the anchor elements, as the image elements are now inside those. You're also setting max height on the image elements but not height, so the images will still be there but may just have zero height. Try adding the following to your style:
.feature-icons a img{
height: 70px;
width: auto;
}
It might also help to see the actual page in case there are other styles overruling what you have here - stand along snippets can be a bit misleading.
Exactly the suggestion I was looking for! I just tested it, and it works like a charm.
Thanks!
Updating the production code now, another happy merchant tomorrow.
See final result at https://www.hairgang.com.au/collections/hair-care/products/eco-lab-firm-hold-hair-spray
(It's holiday season, so my coder is on a three week leave. Yet, didn't want to let the merchant wait till he's back. I thought my limited liquid and html skills would be enough. Now I know I need a crash course CSS 😉
In Canada, payment processors, like those that provide payment processing services t...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025