I am trying to ensure that the width of a div that uses display: flex
is equal to the width of its content.
Below is an example:
#eventDetailElements {
display: flex;
flex-wrap: wrap;
align-items: left;
justify-content: left;
line-height: 175%;
margin: 3%;
border: 1px solid #e2e2e2;
border-radius: 6px;
}
<div id='eventDetailElements'>
<div className='eventDetail'><strong>Location: </strong>Lorem ipsum</div>
<div className='eventDetail'><strong>Starts: </strong> Lorem ipsum</div>
<div className='eventDetail'><strong>Ends: </strong> Lorem ipsum</div>
<div className='eventDetail'><strong>Organiser: </strong>The Organiser</div>
<div className='eventDetail'><strong>Cancellation Policy: </strong>Lorem ipsum</div>
</div>
The width is too long.
I have tried changing my CSS to display: inline-flex
but I get this result:
It is still wider than the content and have moved the last element onto another line.
Where am I going wrong?