Inline-block parent of flex elements in CSS
Instead of the flex value for the display
property, you can set the value of inline-flex
to the parent. In this case, this parent will behave like an inline-block element.
For example, if you don't specify the width of the parent, its width will be formed by the width of its descendants:
<div class="parent">
<div class="child">1</div>
<div class="child">2</div>
<div class="child">3</div>
</div>
.parent {
display: inline-flex;
border: 1px solid red;
}
.child {
width: 50px;
height: 50px;
border: 1px solid green;
}
: