I have a container with two flex items. The last flex item is also a flex container which allows its flex items to wrap. My goal is for that last flex item to only occupy as much space as needed, so that when its children wrap, the two main flex items can be centered within the main flex container.
In other words, I would like the red div to only be as wide as necessary, so that the blue and red divs can be centered within the green div. No matter what classes I apply I can't seem to get this to work.
In this example I am using Tailwind classes, but it's still a general CSS question.
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/1.1.4/tailwind.min.css" rel="stylesheet"/>
<div class="border-2 border-green-500 flex items-center justify-center" style="width:700px;">
<div class="border-2 border-blue-500 mr-2">
Left
</div>
<div class="border-2 border-red-500 flex flex-wrap">
<span>Right side has much longer text that I would like to wrap.</span>
<span>When it wraps why is the red parent still full width?</span>
</div>
</div>
Here's a JSFiddle: https://jsfiddle.net/flyingL123/26jxpqez/12/