Material-ui jss 不尊重证明内容
Material-ui jss doesn't respect justify content
我有一个 React 应用程序,我正在尝试使用 material-ui 1.0 及其 JSS 解决方案。它似乎不响应任何对齐属性。下面的代码我希望居中证明,但它没有发生。我已将代码放在我能想到的每个配置中,但它不起作用。
我觉得可能有些东西命名有误,但 matrial-ui 没有很好地记录它的 jss 解决方案,这是我第一次使用这个系统来设计应用程序。
// react
import React, { Component } from 'react';
import { withStyles } from 'material-ui/styles';
// vendor
import Grid from 'material-ui/Grid';
// source
import LoginPage from 'components/pages/auth-page';
import BasePage from 'components/pages/base';
const styles = theme => ({
root: {
display: "flex",
height: "100%",
[theme.breakpoints.down('sm')]: {
width: "100%",
},
[theme.breakpoints.up('md')]: {
width: "80%",
},
[theme.breakpoints.up('lg')]: {
width: "70%",
},
},
river: {
display: "flex",
marginTop: "75px",
flexGrow: 1,
justifyContent: "center",
alignItems: "center",
},
});
class Application extends Component {
constructor(props){
super(props);
}
render(){
const { classes } = this.props;
return(
<div id={"root"} className={classes.root}>
<Grid container className={classes.river}>
{this.state.authorized
? <BasePage />
: <LoginPage />
}
</Grid>
</div>
)
}
}
export default withStyles(styles)(Application);
你可以试试 Grid it 自己提供的 alignitem 和 justify:
尝试:
<div id={"root"} className={classes.root}>
<div className={classes.river}
<Grid
spacing={0}
direction="column"
alignItems="center"
justify="center"
>
<Grid item xs={3}>
<LoginPage />
</Grid>
</Grid>
</div>
</div>
请发现我使用 xs={3} 作为登录页面的响应宽度。随时更改这些值。
希望对您有所帮助
我有一个 React 应用程序,我正在尝试使用 material-ui 1.0 及其 JSS 解决方案。它似乎不响应任何对齐属性。下面的代码我希望居中证明,但它没有发生。我已将代码放在我能想到的每个配置中,但它不起作用。
我觉得可能有些东西命名有误,但 matrial-ui 没有很好地记录它的 jss 解决方案,这是我第一次使用这个系统来设计应用程序。
// react
import React, { Component } from 'react';
import { withStyles } from 'material-ui/styles';
// vendor
import Grid from 'material-ui/Grid';
// source
import LoginPage from 'components/pages/auth-page';
import BasePage from 'components/pages/base';
const styles = theme => ({
root: {
display: "flex",
height: "100%",
[theme.breakpoints.down('sm')]: {
width: "100%",
},
[theme.breakpoints.up('md')]: {
width: "80%",
},
[theme.breakpoints.up('lg')]: {
width: "70%",
},
},
river: {
display: "flex",
marginTop: "75px",
flexGrow: 1,
justifyContent: "center",
alignItems: "center",
},
});
class Application extends Component {
constructor(props){
super(props);
}
render(){
const { classes } = this.props;
return(
<div id={"root"} className={classes.root}>
<Grid container className={classes.river}>
{this.state.authorized
? <BasePage />
: <LoginPage />
}
</Grid>
</div>
)
}
}
export default withStyles(styles)(Application);
你可以试试 Grid it 自己提供的 alignitem 和 justify:
尝试:
<div id={"root"} className={classes.root}>
<div className={classes.river}
<Grid
spacing={0}
direction="column"
alignItems="center"
justify="center"
>
<Grid item xs={3}>
<LoginPage />
</Grid>
</Grid>
</div>
</div>
请发现我使用 xs={3} 作为登录页面的响应宽度。随时更改这些值。
希望对您有所帮助