本文介绍了如何在材质UI中居中放置按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道如何在材料UI中居中放置按钮。这是我的代码:
I couldn't figure out how to center buttons in material ui. This is the code I have:
function BigCard(props) {
const { classes } = props;
return (
<div>
<Card className={classes.card}>
<CardContent>
<Typography variant="display1" className={classes.title}>
Start Funding!
</Typography>
</CardContent>
<CardActions >
<Button size="small" color="primary" className={classes.actions}>
Share
</Button>
<Button size="small" color="primary">
Learn More
</Button>
</CardActions>
</Card>
</div>
);
如何将按钮居中?
推荐答案
,您可以使用在重要的ui文档中,
you could use the override with classes in the material ui doc,
第一路
您可以做类似的事情:
//Add your justify css in your styles const
const styles = {
...
root: {
justifyContent: 'center'
}
};
并使用类道具将其添加到CardActions组件中:
And use the classes props to add this to your CardActions component :
<CardActions classes={{root: classes.root}}>
第二种方式(更简便)
或您可以直接在组件上使用样式,但是如果您大量使用material-ui,我建议您培训如何使用类
OR You can use the style directly on your component, but i advise you to train how to use classes if you're working alot with material-ui
只需执行以下操作即可:
Just do something like :
<CardActions style={{justifyContent: 'center'}}>
这篇关于如何在材质UI中居中放置按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!