Equal width columns in CSS Grid

后端 未结 7 1269
别跟我提以往
别跟我提以往 2020-12-25 10:27

I\'d like to have the html below showing in n equal columns whether there are two, or three, or more child elements to the row element using css grid - Flexbox makes this ea

7条回答
  •  情书的邮戳
    2020-12-25 10:47

    This allows the columns to distribute better, and the columns are the same size regardless of whether the size of the items does not adjust.

    .row {
      display: grid;
      grid-template-columns: repeat( auto-fit, minmax(33.33%, 1fr) );
    }
    .item {
      grid-column: span 1;
    }
    

提交回复
热议问题