I have a flex container with two flex items. The first flex item should determine the width of the container, and the second flex item should wrap around it. I’m using Tailwind CSS for styling, but I can’t seem to get the desired layout.
Here’s my current code:
<div class="flex flex-col">
<div class="flex-initial w-2/3 bg-blue-500 p-4"> <!-- The first child -->
<!-- Content of the first child -->
</div>
<div class="bg-red-500 p-4"> <!-- All the rest components wrap around it -->
<!-- Content of the rest components -->
</div>
</div>
I’ve tried using w-2/3 to set the width of the first child, but the second child still takes up all the available space in the container. How can I make the second flex item wrap around the first item and have the first item determine the container’s width?
Any help or guidance would be greatly appreciated! Thanks in advance!
2
Answers
I’m not sure if I totally understand your question, but here’s what I think is the solution:
div
something likew-56
div
aw-fit
classI am not completely sure what you mean, but from what I understand you want the second element to be the rest (but not 100% of available space?)
If this is not what you need, would you be able to provide a quick sketch of some sort to make it easier to visualize, and help you further.