CSS Grid Perfect Tetris/Metro Layout? [duplicate]












0
















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 | -------
| |
------------









share|improve this 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.























    0
















    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 | -------
    | |
    ------------









    share|improve this 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.





















      0












      0








      0









      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 | -------
      | |
      ------------









      share|improve this question















      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      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.


























          1 Answer
          1






          active

          oldest

          votes


















          0














          It appears my question is a duplicate of CSS-only masonry layout. Thanks to Michael_B for finding that.






          share|improve this answer






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            It appears my question is a duplicate of CSS-only masonry layout. Thanks to Michael_B for finding that.






            share|improve this answer




























              0














              It appears my question is a duplicate of CSS-only masonry layout. Thanks to Michael_B for finding that.






              share|improve this answer


























                0












                0








                0







                It appears my question is a duplicate of CSS-only masonry layout. Thanks to Michael_B for finding that.






                share|improve this answer













                It appears my question is a duplicate of CSS-only masonry layout. Thanks to Michael_B for finding that.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 2 at 1:39









                Sam ClausSam Claus

                652722




                652722

















                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas