CSS Grid Perfect Tetris/Metro Layout? [duplicate]
This question already has an answer here:
CSS-only masonry layout
1 answer
I have a grid with 3 template columns of 320px
and completely implicit rows of 20px
. A bunch of random dashboard cards will be placed in the grid, every card with its own intrinsic width and height based on content (graph, text description, etc). I would like the grid to automatically fit the cards as closely as possible, left-to-right and top-to-bottom.
I thought putting auto / auto
for grid-row
and grid-column
on each of the cards would do the trick, by just automatically placing them in the next available spots and taking up as many columns and rows as necessary, but it did nothing and all the cards are squished to a single tiny row and one column.
Let's say I have 4 cards in this order: A, B, C, D.
Desired Effect
-------------------- --------
| | | |
| A | | |
| | | |
-------------------- | B |
------------ ------- | |
| | | D | | |
| C | ------- | |
| | --------
------------
Using Flexbox (Row)
-------------------- ---------
| | | |
| A | | |
| | | |
-------------------- | B |
| |
wasted space | |
feelsbadman | |
---------
------------ -------
| | | D |
| C | -------
| |
------------
css css-grid metro-ui-css
marked as duplicate by Sam Claus, Community♦ Jan 2 at 1:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
CSS-only masonry layout
1 answer
I have a grid with 3 template columns of 320px
and completely implicit rows of 20px
. A bunch of random dashboard cards will be placed in the grid, every card with its own intrinsic width and height based on content (graph, text description, etc). I would like the grid to automatically fit the cards as closely as possible, left-to-right and top-to-bottom.
I thought putting auto / auto
for grid-row
and grid-column
on each of the cards would do the trick, by just automatically placing them in the next available spots and taking up as many columns and rows as necessary, but it did nothing and all the cards are squished to a single tiny row and one column.
Let's say I have 4 cards in this order: A, B, C, D.
Desired Effect
-------------------- --------
| | | |
| A | | |
| | | |
-------------------- | B |
------------ ------- | |
| | | D | | |
| C | ------- | |
| | --------
------------
Using Flexbox (Row)
-------------------- ---------
| | | |
| A | | |
| | | |
-------------------- | B |
| |
wasted space | |
feelsbadman | |
---------
------------ -------
| | | D |
| C | -------
| |
------------
css css-grid metro-ui-css
marked as duplicate by Sam Claus, Community♦ Jan 2 at 1:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
CSS-only masonry layout
1 answer
I have a grid with 3 template columns of 320px
and completely implicit rows of 20px
. A bunch of random dashboard cards will be placed in the grid, every card with its own intrinsic width and height based on content (graph, text description, etc). I would like the grid to automatically fit the cards as closely as possible, left-to-right and top-to-bottom.
I thought putting auto / auto
for grid-row
and grid-column
on each of the cards would do the trick, by just automatically placing them in the next available spots and taking up as many columns and rows as necessary, but it did nothing and all the cards are squished to a single tiny row and one column.
Let's say I have 4 cards in this order: A, B, C, D.
Desired Effect
-------------------- --------
| | | |
| A | | |
| | | |
-------------------- | B |
------------ ------- | |
| | | D | | |
| C | ------- | |
| | --------
------------
Using Flexbox (Row)
-------------------- ---------
| | | |
| A | | |
| | | |
-------------------- | B |
| |
wasted space | |
feelsbadman | |
---------
------------ -------
| | | D |
| C | -------
| |
------------
css css-grid metro-ui-css
This question already has an answer here:
CSS-only masonry layout
1 answer
I have a grid with 3 template columns of 320px
and completely implicit rows of 20px
. A bunch of random dashboard cards will be placed in the grid, every card with its own intrinsic width and height based on content (graph, text description, etc). I would like the grid to automatically fit the cards as closely as possible, left-to-right and top-to-bottom.
I thought putting auto / auto
for grid-row
and grid-column
on each of the cards would do the trick, by just automatically placing them in the next available spots and taking up as many columns and rows as necessary, but it did nothing and all the cards are squished to a single tiny row and one column.
Let's say I have 4 cards in this order: A, B, C, D.
Desired Effect
-------------------- --------
| | | |
| A | | |
| | | |
-------------------- | B |
------------ ------- | |
| | | D | | |
| C | ------- | |
| | --------
------------
Using Flexbox (Row)
-------------------- ---------
| | | |
| A | | |
| | | |
-------------------- | B |
| |
wasted space | |
feelsbadman | |
---------
------------ -------
| | | D |
| C | -------
| |
------------
This question already has an answer here:
CSS-only masonry layout
1 answer
css css-grid metro-ui-css
css css-grid metro-ui-css
asked Jan 2 at 1:07
Sam ClausSam Claus
652722
652722
marked as duplicate by Sam Claus, Community♦ Jan 2 at 1:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Sam Claus, Community♦ Jan 2 at 1:39
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It appears my question is a duplicate of CSS-only masonry layout. Thanks to Michael_B for finding that.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It appears my question is a duplicate of CSS-only masonry layout. Thanks to Michael_B for finding that.
add a comment |
It appears my question is a duplicate of CSS-only masonry layout. Thanks to Michael_B for finding that.
add a comment |
It appears my question is a duplicate of CSS-only masonry layout. Thanks to Michael_B for finding that.
It appears my question is a duplicate of CSS-only masonry layout. Thanks to Michael_B for finding that.
answered Jan 2 at 1:39
Sam ClausSam Claus
652722
652722
add a comment |
add a comment |