css - 将 CSS 网格行分成相等的大小

标签 css

<分区>

如何将具有 3 列的 CSS 网格行分成 2 个相等的大小?这是我的 fiddle :

https://jsfiddle.net/251f04ts/3/

.wrapper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 10px;
  grid-auto-rows: 50px;
}

.one {
  background-color: yellow;
}

.two {
  background-color: blue;
}

.three {
  background-color: purple;
}

.four {
  background-color: green;
  grid-column: 1/4;
}

.five {
  background-color: pink;
  grid-column: 1/3;
}

.six {
  background-color: gray;
  grid-column: 2/5;
}
<div class="wrapper">

  <div class="one">
    one
  </div>
  <div class="two">
    two
  </div>
  <div class="three">
    three
  </div>
  <div class="four">
    four
  </div>
  <div class="five">
    five - this and six should be equal
  </div>
  <div class="six">
    six
  </div>

</div>

enter image description here

最佳答案

.wrapper_the_second 放入您想要 .five.six 的行中。

.wrapper_the_second{
  grid-column: 1/4;

  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 10px;
  grid-auto-rows: 50px;
}

然后

.five {
  background-color: pink;
}

.six {
  background-color: gray;
}

这应该可以完成工作。


Jfiddle:https://jsfiddle.net/9e1naudg/

关于css - 将 CSS 网格行分成相等的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58977119/

上一篇:jquery 模态对话框按钮 div 不对齐 - css 使其占据总行

下一篇:html - 已安装 Div 覆盖框架

相关文章:

javascript - 将所有元素包装在一个元素中,直到出现特定标记

jquery - IE7,悬停 div 仅对鼠标悬停在边框上有反应

twitter-bootstrap - CSS 使圆 Angular 成为具有百分比半径的圆

html - 为什么这个 DIV 容器的大小调整不一致?

CSS:右侧菜单位于页脚上方

css - sticky-top 不适用于 Angular8/safari

javascript - 在特定元素的某个点将垂直滚动更改为水平滚动

jquery - 将浮点值赋予 html 标签 Internet Explorer 的 css "left"

jquery - 使用 jQuery 调整 css

php - 在 Woocommerce CSS 之后加载子主题 CSS