I want to add a CSS container query container for my 2nd child in my flexbox where both children are spaced out using space-between
but it is not working. My second child goes off-screen and when I inspect the size of the div.container
it says 0px width. What am I doing wrong here?
Here is my code:
body {
background: #2b2e36;
color: white;
font-size: 20px;
}
.container {
container-type: inline-size;
background-color: green;
}
.parent {
width: 100%;
display: flex;
justify-content: space-between;
background: #ffff0061;
}
.child {
background-color: #ff000091;
}
<div class="parent">
<div class="child">
<div>First</div>
</div>
<div class="container">
<div>Second</div>
</div>
</div>
Here is a working fiddle: https://jsfiddle.net/kpx6gvn9/