rachelandrew / cssgrid-ama

Ask me anything about CSS Grid Layout
323 stars 12 forks source link

Auto span itme to new row when it over flow #167

Open perymimon opened 2 years ago

perymimon commented 2 years ago

let assume

grid-template-columns: repeat(auto-fill, 11em);
grid-auto-rows: 10em;

And for one item (the first one) I want it auto span for the next row if its content overflows 10em;

how it can be possible?

webcraftsman commented 2 years ago

@perymimon My understanding is that an item will only span 1 row or column unless specified in your CSS to span 2 or more. You could use Javascript to check if an item has a height over 10em and then add a class to that item and write CSS to make it span 2 rows. Otherwise, I don't think there is a way to accomplish it with just CSS and with the code you have above.