I have a parent which its display propertis is inline-block
.
and it has some children that their display is also inline-block
. The width of children are fixed, 250px. And the design is responsive.
I expect the parent div's width to collapse to the width of children, when there are more than one line of children, but it doesn't.
In the example, to get rid of that 150px red background in the right side of the parent.
What Should I do?
.parent{
display: inline-block;
width: 400px;
background-color: red;
}
.child{
display: inline-block;
width: 250px;
height: 60px;
background-color: blue;
}
<div class="parent">
<div class="child">
</div>
<div class="child">
</div>
</div>