I am trying to maximize an item by using the flex-grow
property. However, I have encountered some issues with my code:
div {
display: flex;
flex-direction: column;
border: 1px solid #A8F;
}
span {
flex-basis: 0px;
flex-grow: 0;
flex-shrink: 0;
overflow: hidden;
border: 1px solid #8AF;
}
span.selected {
flex-basis: 0px;
flex-grow: 1;
border: 1px solid #FA8;
}
<div>
<span>Item 1</span>
<span class="selected">Item 2</span>
</div>
When running the code above, nothing is displayed as expected. The item with the class selected
should be taking up all available space due to flex-grow: 1
, but it remains at 0px.
What could be causing this 0px height issue in my CSS?
EDIT: For those facing a similar problem, I managed to solve it by using JavaScript to dynamically adjust the height of the container based on the content inside. By manipulating the flex properties, you can achieve smooth animations.