Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • I've edited your grid-based answer to demonstrate that it does work correctly, even if the final row has fewer items. To prove it works in that case. (Feel free to revert if you don't like this change.) Commented Oct 29, 2019 at 13:17
  • As per this question they have only asked to fill the space properly with the child elements without a hack, that what I did, using grid we can manage as per the grid-template-columns we define not dynamically. So if you give the value to 1fr 1fr 1fr 1fr then it will split the div into 4fractions and try to fill the child elements in each fractions, in my knowledge thats the only way in grid. What I have stated in the answer is that if the user needs to split the div into 4 and use them with many elements even for multiple rows, the gid will help. Commented Oct 31, 2019 at 5:25