首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >资料-用户界面排版不以工具条为中心

资料-用户界面排版不以工具条为中心
EN

Stack Overflow用户
提问于 2020-06-01 14:49:50
回答 2查看 1.8K关注 0票数 0

我正在尝试将文本集中在AppBar中。我试着在排版元素中对文本进行居中,使用align="center“、textAlign="center”和style={ align:“中间”}、style= ="center“--它仍然不起作用。我该怎么把课文集中起来?

代码语言:javascript
复制
              return (
               <MuiThemeProvider theme={theme}>
               <React.Fragment>
              <div alignItems="center" justify="center">
               <AppBar position="static">
                 <Toolbar>
                 <Typography style={{ align: "center" }}>
                  Best Practices Management System
                  </Typography>
                  </Toolbar>
                  </AppBar>
                   </div>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-06-01 16:43:58

align='center'应该是解决方案,但您必须使用父元素的100%宽度。

更新:

代码语言:javascript
复制
import React from 'react';
import Typography from '@material-ui/core/Typography';
import {makeStyles} from '@material-ui/core/styles';
import {MuiThemeProvider} from "@material-ui/core";
import AppBar from "@material-ui/core/AppBar";
import Toolbar from "@material-ui/core/Toolbar"
import { createMuiTheme } from '@material-ui/core/styles';
import blue from '@material-ui/core/colors/blue';

const useStyles = makeStyles({
    root: {
        width: '100%',
        maxWidth: 500,
    },
});


const theme = createMuiTheme({
  palette: {
    primary: blue,
  },
});

export default class TypographyExamples extends React.Component {
    render() {
        const {values, handleChange} = this.props;
        return (
            <MuiThemeProvider theme={theme}>
                <React.Fragment>
                    <div className={useStyles.root}>
                        <AppBar position="static">
                            <Toolbar>
                                <Typography gutterBottom align="center" style={{width: "100%", alignItems: "center"}}> abc </Typography>
                            </Toolbar>
                        </AppBar>
                    </div>
                </React.Fragment>
            </MuiThemeProvider>
        );
    }
}

请检查此代码沙箱

票数 0
EN

Stack Overflow用户

发布于 2020-06-01 15:00:48

材料本身的排版就像支柱一样对齐

代码语言:javascript
复制
<Typography align='center'>
    Best Practices Management System
</Typography>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62134861

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档