I want to have the sponsored text and image wrap to the bottom of the logo on mobile but flex-wrap does not seem to be doing it. I would like the 50×50 image and the ‘sponsored by" text to go underneath the 80×80 image below 1024px (side by side). Thanks
console.clear();
<script src="https://cdn.tailwindcss.com"></script>
<div class="inline-block relative bottom-2 right-1">
<span class="inline-flex items-center text-blue">
<img src="https://placehold.co/80x80"/>
<div class="flex justify-center text-black">
<div class="mt-2 ml-0.5 sm:text-sm text-[10px] flex-wrap lg:flex">sponsored by</div>
<img class="mt-0.25 pl-0.5 object-scale-down flex-wrap lg:flex" src="https://placehold.co/50x50" />
</div>
</span>
</div>
2
Answers
Flex-wrap applies to the children of the element on which it’s applied, so you need to move that class. This would result in the elements wrapping when there’s not enough space. This demo shows that.
If you want to wrap at a particular breakpoint instead you need to use something like a block-level wrapper for small screens and transition to inline-block for larger screens.
I added the
flex-wrap
class to the outer span element to enable flex wrapping for smaller screens. Additionally, I modified the structure inside the span to useflex-col
for mobile(flex-col sm:flex-row)
, ensuring that the "sponsored by" text and the 50×50 image are displayed in a column layout on smaller screens and side-by-side on screens larger than 640px.