【发布时间】:2020-08-17 11:57:06
【问题描述】:
我正在尝试在我的 React 16.13.0 应用程序中使用 material-ui 的 Grid 组件。我想要一行包含三个项目。前两项应该只占用他们需要的空间(如果可能的话,我不想硬编码像素值)。我希望第三个项目占据剩余的水平空间并最远地浮动到 rigth (虽然我发现 React 不喜欢“float: right”作为一种样式)。我有这个
const styles = (theme) => ({
root: {
textAlign: "left",
margin: theme.spacing(2),
paddingBottom: theme.spacing(1),
color: theme.color.secondary,
},
cardHeader: {
paddingBottom: theme.spacing(0),
},
cardContent: {
width: "100%",
paddingBottom: theme.spacing(1),
},
rowBody: {
width: "100%",
flexWrap: "nowrap",
alignItems: "center",
},
});
...
<CardContent className={classes.cardContent}>
<Grid container className={classes.rowBody}>
<Grid item>
<img height="20" src={require('../../img/apple.svg')} alt="" />
</Grid>
<Grid item>
{title}
</Grid>
<Grid item>
<InfoIcon />
</Grid>
</Grid>
但不幸的是,这会将所有内容都捆绑在一起
如何调整样式以达到我想要的效果?
编辑:这是根据@Mohsen007给出的答案显示的内容...
【问题讨论】:
标签: css reactjs grid material-ui