如何删除最后一个差距网格

发布于 2025-02-08 18:40:51 字数 1734 浏览 1 评论 0原文

我应该如何制作5个盒子的布局?到目前为止,这就是我所能做的。但是问题在于,网格的最后一项仍然在其下方有差距。 我只能为容器提供样式的组件。

const Container = styled('div')`
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 2fr 3fr 1fr;
  grid-template-rows: 5fr 0.75fr 1fr;
  gap: 10px;
  & > div {
    min-height: 20px;
  }
  & > .container-live-call {
    grid-column: 1 / span 3;
    background-color: ${({ theme }) => theme.color.secondary.$100};
  }
  & > .container-live-call-map {
    grid-row: 2 / span 3;
    background-color: ${({ theme }) => theme.color.secondary.$100};
  }
  & > .container-live-call-info {
    grid-row: 2 / span 3;
    background-color: ${({ theme }) => theme.color.secondary.$100};
  }
  & > .container-live-call-volume {
    grid-column: 3;
    background-color: ${({ theme }) => theme.color.secondary.$100};
  }
  & > .container-live-call-voice {
    grid-column: 3;
    background-color: ${({ theme }) => theme.color.secondary.$100};
  }
`;
      <Container>
        <div className="container-live-call"></div>
        <div className="container-live-call-map"></div>
        <div className="container-live-call-info"></div>
        <div className="container-live-call-volume"></div>
        <div className="container-live-call-voice">
          <button onClick={() => setOpen(false)}>Click me to close</button>
        </div>
      </Container>

How should I make a layout with 5 boxes ? So far, this is all I can do. But the problem is that the last item of the grid still has a gap below it.
I only able to provide styled component for Container.

const Container = styled('div')`
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 2fr 3fr 1fr;
  grid-template-rows: 5fr 0.75fr 1fr;
  gap: 10px;
  & > div {
    min-height: 20px;
  }
  & > .container-live-call {
    grid-column: 1 / span 3;
    background-color: ${({ theme }) => theme.color.secondary.$100};
  }
  & > .container-live-call-map {
    grid-row: 2 / span 3;
    background-color: ${({ theme }) => theme.color.secondary.$100};
  }
  & > .container-live-call-info {
    grid-row: 2 / span 3;
    background-color: ${({ theme }) => theme.color.secondary.$100};
  }
  & > .container-live-call-volume {
    grid-column: 3;
    background-color: ${({ theme }) => theme.color.secondary.$100};
  }
  & > .container-live-call-voice {
    grid-column: 3;
    background-color: ${({ theme }) => theme.color.secondary.$100};
  }
`;
      <Container>
        <div className="container-live-call"></div>
        <div className="container-live-call-map"></div>
        <div className="container-live-call-info"></div>
        <div className="container-live-call-volume"></div>
        <div className="container-live-call-voice">
          <button onClick={() => setOpen(false)}>Click me to close</button>
        </div>
      </Container>

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过度放纵 2025-02-15 18:40:51

.container-live-call-map.container-live-call-info规则正在为4个行增加一个行(而不是<<<<3代码>网格 - 板行),因为它们从第2行开始,跨越了3行。如果将它们更改为:

.container  > .container-live-call-map {
    grid-row: 2 / span 2;
}
.container  > .container-live-call-info {
    grid-row: 2 / span 2;
}

这应该摆脱在网格的最后一件以下的额外行/间隙。

The .container-live-call-map and .container-live-call-info rules are adding an additional row to 4 total rows (instead of 3 as defined in grid-template-rows) because they are starting at row 2 and spanning 3 rows. If you change them to:

.container  > .container-live-call-map {
    grid-row: 2 / span 2;
}
.container  > .container-live-call-info {
    grid-row: 2 / span 2;
}

This should get rid of that extra row/gap below the last item of the grid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文