【发布时间】:2026-02-05 03:35:02
【问题描述】:
我需要在设置了 minHeigh 属性的网格项内垂直居中文本,here's short codesandbox example of the problem i'm facing、justify、alignItems,似乎不起作用。
<Grid container className={classes.root}>
<Grid item xs={12}>
<Grid
container
spacing={16}
className={classes.demo}
alignItems={alignItems}
direction={direction}
justify={justify}
>
{[0, 1, 2].map(value => (
<Grid
key={value}
item
style={{
padding: "0 12px",
minHeight: 48,
borderStyle: "solid"
}}
>
{`Cell ${value + 2}`}
</Grid>
))}
</Grid>
</Grid>
当style={{ minHeight: 48 }} 应用于<Grid item /> 网格项的子项未对齐时,justify、alignItems 对其没有任何影响。
【问题讨论】:
-
请提供有关您的问题的更多详细信息,并将您的相关代码直接添加到您的问题中。这样可以更轻松地为您提供帮助,谢谢!
-
您能给我们一些您的代码吗?这肯定有助于找到解决方案
标签: javascript css reactjs