Expand a div to fill the remaining width

前端 未结 21 1213
一生所求
一生所求 2020-11-21 22:21

I want a two-column div layout, where each one can have variable width e.g.

21条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 23:02

    You can try CSS Grid Layout.

    dl {
      display: grid;
      grid-template-columns: max-content auto;
    }
    
    dt {
      grid-column: 1;
    }
    
    dd {
      grid-column: 2;
      margin: 0;
      background-color: #ccc;
    }
    lorem ipsum
    dolor sit amet
    carpe
    diem

提交回复
热议问题