You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Material UI嵌套Grid的Item未占满可用宽度且缩小时UI损坏如何解决

Material UI嵌套Grid布局异常问题

我在使用Material UI的嵌套Grid系统时,遇到Grid Item仅占用固定宽度、剩余可用空间留白的问题。当可用空间不足以容纳该固定宽度时,组件不会挤压内部空闲空间,反而直接导致UI布局损坏。

相关截图(拍摄环境:Google Chrome)

  • 外层Grid
  • 外层Grid Item 1
  • 外层Grid Item 2
  • 内层Grid系统
  • 开始缩小视口
  • UI损坏,但第二个组件宽度未发生变化

代码片段

外层Grid代码

<Grid container justifyContent="space-evenly" direction={isMd ? "row" : "column"}>
  <Grid item sx={{ minWidth: "300px" }}>
    <Typography>Component coming soon</Typography>
  </Grid>
  <Grid item component={Footer2}></Grid>
</Grid>

内层Grid代码

<Grid
  container
  justifyContent="space-evenly"
  direction={isMd ? "row" : "column"}
  gap={6}
>
  <Grid item links={["COMPANY", "About", "Experts and Spokesmodels"]}>
    <Listings
      links={["COMPANY", "About", "Experts and Spokesmodels"]}
    ></Listings>
  </Grid>
  <Grid item>
    <Listings
      links={[
        "CUSTOMER SERVICE",
        "Contact Us",
        "My Account",
        "Store Locator",
        "Redeem Rewards"
      ]}
    ></Listings>
  </Grid>
  <Grid item>
    <Listings
      links={[
        "MORE TO EXPLORE",
        "Beauty Magazine",
        "Tools and Consultations",
        "Offers",
        "#LorealParis"
      ]}
    ></Listings>
  </Grid>
</Grid>

内容的提问来源于stack exchange,提问作者Julia Anderson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 00:21:04