Reverse order of columns in CSS Grid Layout

后端 未结 6 1946
日久生厌
日久生厌 2020-12-08 19:05

I was hoping to use CSS Grid to reverse the apparent order of two side-by-side divs, where one of the divs grows arbitrarily (I don\'t want to use floats).

I\'ve c

6条回答
  •  爱一瞬间的悲伤
    2020-12-08 20:05

    I found out: I need to apply grid-auto-flow: dense; on the container:

    #container {
      grid-template-columns: 240px 1fr;
      display: grid;
      grid-auto-flow: dense;
    }
    

    According to MDN, this algorithm attempts to fill in holes earlier in the grid.

提交回复
热议问题