How to make CSS Grid items take up remaining space?

前端 未结 6 2071
深忆病人
深忆病人 2020-12-03 10:16

I have a card built with CSS Grid layout. There might be an image to the left, some text to the right top and maybe a button or a link at the right bottom.

In the co

6条回答
  •  一整个雨季
    2020-12-03 10:39

    A possible approach might be grouping two and three together, and using flexbox:

    .grid {
      display: grid;
      grid-template-columns: 1fr 3fr;
      grid-template-areas: "one two"
    }
    
    .one {
      background: red;
      grid-area: one;
      padding: 50px 0;
    }
    
    .wrap {
      grid-area: two;
      display: flex;
      flex-direction: column;
    }
    
    .two {
      background: green;
      flex: 1;
    }
    
    .three {
      background: blue;
    }
    One
    Two
    Three

提交回复
热议问题