search

Home  >  Q&A  >  body text

How to use columns in a grid to wrap flex horizontally?

<p>https://codepen.io/itaied246/pen/eYbOWjm</p> <p>I successfully created a flexbox with vertical scrolling that fills the space horizontally and scrolls down. </p> <p>I want to do the same thing horizontally, i.e. fill the space vertically and scroll to the right. </p> <p>My <code>flex</code> div is inside a corresponding <code>grid</code> with its <code>max-content</code>. </p><p> What did I miss? </p>
P粉481035232P粉481035232499 days ago547

reply all(1)I'll reply

  • P粉143640496

    P粉1436404962023-08-17 15:47:05

    You need to set a height on your flexbox. In this case, simply adding height: 400px to the .flex-columns class will solve the problem.

    The reason is that your flexbox assumes it can be as tall as possible, and since the flex direction is set to columns, it puts everything into one column. It's easier to visualize when the flexbox is a row!

    reply
    0
  • Cancelreply