[英]Center a material-ui React component in a footer element
I am trying to center a material-ui Simple Breadcrumbs component within a footer instead of it being left aligned.我正在尝试将 material-ui Simple Breadcrumbs 组件居中在页脚内,而不是左对齐。 I'm new to this and I feel that this should be pretty straightforward but I can't figure it out.我对此很陌生,我觉得这应该很简单,但我无法弄清楚。 I've tried setting the text-alignment property to center and that hasn't worked.我尝试将 text-alignment 属性设置为 center,但没有奏效。
function Footer() { return ( <footer> <SimpleBreadCrumbs /> </footer> ); } export default Footer;
export default function SimpleBreadcrumbs() { let year = new Date().getFullYear(); return ( <Breadcrumbs className="breadcrumbs" aria-label="breadcrumb"> <Link color="inherit" href="/" onClick={handleClick}> Material-UI </Link> <Link color="inherit" href="/getting-started/installation/" onClick={handleClick}> Core </Link> <Typography color="textPrimary">Copyright © {year}</Typography> </Breadcrumbs> ); }
You can use flex to center the SimpleBreadCrumbs component.您可以使用 flex 使 SimpleBreadCrumbs 组件居中。
function Footer() {
const style = {
display: 'flex',
justifyContent: 'center'
};
return (
<footer style={style}>
<SimpleBreadCrumbs />
</footer>
);
}
export default Footer;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.