CSS grid wrapping

前端 未结 5 910
借酒劲吻你
借酒劲吻你 2020-12-04 04:53

Is it possible to make a CSS grid wrap without using media queries?

In my case, I have a non-deterministic number of items that I want placed in a grid and I want th

5条回答
  •  星月不相逢
    2020-12-04 05:44

    I had a similar situation. On top of what you did, I wanted to center my columns in the container while not allowing empty columns to for them left or right:

    .grid { 
        display: grid;
        grid-gap: 10px;
        justify-content: center;
        grid-template-columns: repeat(auto-fit, minmax(200px, auto));
    }
    

提交回复
热议问题