javascript - react : how to get Material UI's grid spacing to work?

标签 javascript css reactjs material-ui

我正在使用 Material UI 的网格 (https://material-ui.com/api/grid) 进行布局,但是当列和行工作正常时,spacing属性似乎不起作用。

我已经这样导入了 Grid:import Grid from '@material-ui/core/Grid'

  <Grid container spacing={10}>
    <Grid item xs={12} sm={6}>
      CONTENT
    </Grid>
    <Grid item xs={12} sm={6}>
      CONTENT
    </Grid>
  </Grid>

但没有出现填充。

有谁知道我可以在网格中包含间距吗?

最佳答案

对我来说,问题是我没有将元素用于网格元素。

<Grid container spacing={3}>
    <Grid item xs={12}></Grid>
    <Grid item xs={12}></Grid>
</Grid>

关于javascript - react : how to get Material UI's grid spacing to work?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60406840/

相关文章:

reactjs - 如何将 RTK Query apiSlice reducer 与常规 RTK reducer 混合使用?

javascript - 为什么 Angular JS Controller 的作用域变量不将 this 设置为 true?

javascript - Window.showModalDialog 替换

jquery - 是否可以使用 jQuery.Support 检查 PNG 支持?

html - 如何修复我的页脚和本页底部?

html - 表格嵌套在表格单元格内

javascript - 如何向 TS 表明 store 中的值是有值(value)的,即使它是可选的?

javascript - JSX 脚本在 Photoshop 中输出多个不同名称的图像

javascript - 您可以在 javascript 中使用模板文字创建对象属性名称吗?

html - margin 突然出现