I am confused as to why a flex div takes up 100% width of its parent element. Take the following snippet:
#wrapper {
width: 100%;
height: 100px;
background: green;
}
#flex {
color: white;
display: flex;
flex-direction: row;
background: blue;
}
<div id="wrapper">
<div id="flex">
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
</div>
</div>
Why is the flex div expanding to 100% width of the parent? Is there a way to make the flex div only as wide as the contents within it?
Any help appreciated, Thanks