To do this, you need to set the maximum height for the flex container, not flex items, because you want the flex items to be aligned in columns and larger columns for wider screens, and you don't want the flex items to resize, so set this relative value for flex container:
.card-container { max-height: 100vh }
Add this to the flex container. Here, "vh" is a relative unit denoting "Viewport Height". 1 vh = 1% of the height of the viewport. Viewport = browser window size. If the viewport has a height of 50 cm, 1 vh = 0.5 cm.
Thus, no matter how wide the screen is, how many cards you insert, how large the cards will be, several columns will be used when the height of the content is greater than the height of the viewport.
They will also create horizontal scrollbars on displays that are set to a narrower width than the content. Therefore, if you do not want the scroll bars to be displayed, this can be eliminated using multimedia queries.
source share