Gau*_*ngh 2 javascript reactjs material-design material-ui
我找不到将标题置于 React Material UI AppBar 中心的方法。也许我错过了一些东西。StackOverflow 上几乎没有其他答案,但这些似乎不是最好的方法。
使用material-ui makeStyles将文本居中:
import { makeStyles } from '@material-ui/core/styles';
const useStyles = makeStyles(theme => ({
title: {
flexGrow: 1,
textAlign: 'center',
},
}));
Run Code Online (Sandbox Code Playgroud)
然后将“标题”样式应用于您的标题组件:
export default function CenteredTextAppBar() {
const classes = useStyles();
return (
<div>
<AppBar position="static">
<Toolbar>
<Typography variant="h6" className={classes.title}>
Centered Text
</Typography>
</Toolbar>
</AppBar>
</div>
);
}
Run Code Online (Sandbox Code Playgroud)
您可以参考这个CodeSandbox示例。
归档时间: |
|
查看次数: |
3935 次 |
最近记录: |