相关疑难解决方法(0)

如何使CSS Grid项占用剩余空间?

我有一个使用CSS Grid布局构建的卡.左侧可能有图像,右上角可能有文本,右侧底部可能有按钮或链接.

在下面的代码中,如何让绿色区域占用尽可能多的空间,同时使蓝色区域占用尽可能小的空间?

绿色应该尽可能地将蓝色区域向下推.

https://jsfiddle.net/9nxpvs5m/

.grid {
  display: grid;
  grid-template-columns: 1fr 3fr;
  grid-template-areas:
    "one two"
    "one three"
}

.one {
  background: red;
  grid-area: one;
  padding: 50px 0;
}

.two {
  background: green;
  grid-area: two;
}

.three {
  background: blue;
  grid-area: three;
}
Run Code Online (Sandbox Code Playgroud)
<div class="grid">
  <div class="one">
    One
  </div>
  <div class="two">
    Two
  </div>
  <div class="three">
    Three
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

html css grid css3 css-grid

18
推荐指数
1
解决办法
2万
查看次数

标签 统计

css ×1

css-grid ×1

css3 ×1

grid ×1

html ×1