Reputation: 43
How can I set the width of the flexbox container to the width of the content within? Can it behave like display:inline-block
, without specifying a fixed width
Upvotes: 2
Views: 88
Reputation: 738
Try this
.parent {
width: 150px;
height: 150px;
background: yellow;
text-align: center;
}
.flex {
display: inline-flex;
margin: auto;
justify-content: center;
background: blue;
}
Upvotes: 2