使用ReactJS在Material-UI AppBar中将标签水平居中

扎克·布朗

我正在使用Material-UI构建一个React App,无法弄清楚如何在蓝色AppBar中将3个选项卡居中。当前,它们都是左对齐的,例如:

https://i.imgur.com/MjQIuBl.png(还不能嵌入图片,我很抱歉)

这是我的代码:

<div>
  {/* Tabs */}
  <AppBar position="static" color="primary" style={{ position: 'fixed' }}>
    <Tabs
      fullWidth={true}
      value={this.state.value}
      onChange={this.handleChange}
      indicatorColor="secondary"
    >
      <Tab label="Passenger" icon={Icons.seatIcon} component={Link} to="/passenger" />
      <Tab label="Driver" icon={Icons.driverIcon} component={Link} to="/driver" />
      <Tab label="Settings" icon={Icons.settingsIcon} component={Link} to="/settings" />
    </Tabs>
  </AppBar>
</div>

我从相似的问题中尝试了许多不同的CSS属性,但是还没有接近。谢谢你的帮助!

凯文·格尔普斯

尝试将“居中”添加到Tabs组件,如下所示:

    <div>
  {/* Tabs */}
  <AppBar position="static" color="primary" style={{ position: 'fixed' }}>
    <Tabs
      fullWidth={true}
      value={this.state.value}
      onChange={this.handleChange}
      indicatorColor="secondary"
      centered
    >
      <Tab label="Passenger" icon={Icons.seatIcon} component={Link} to="/passenger" />
      <Tab label="Driver" icon={Icons.driverIcon} component={Link} to="/driver" />
      <Tab label="Settings" icon={Icons.settingsIcon} component={Link} to="/settings" />
    </Tabs>
  </AppBar>
</div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Material-UI中将AppBar中的多行垂直居中

ReactJS水平对齐Material-UI元素

如何在Material UI网格项目中将项目水平居中?

使用 Material-ui 时如何保持在 ReactJS 中选择标签?

Material-UI版式不在AppBar中居中

AppBar Material UI问题

如何在Material-UI中将CardHeader标题居中?

如何在Material-UI中将组件居中并使之响应?

如何部署AppBar Material UI?

ReactJS + Redux:如何使用Material-UI的RaisedButton作为<input />?

ReactJS Material UI 如何使用 DatePicker、LocalizationProvider、AdapterDateFns

如何在ReactJS Material UI中使用useStyle?

如何通过Webpack的外部使用CDN导入ReactJS Material UI?

使用reactjs和Material UI单击按钮时更改内容

使用Appbar +抽屉(材料UI + ReactJS)时遇到问题

Material-ui水平菜单

使用 Material-Ui 和 CSS 水平对齐标题

如何使用React Material UI实现多行标签

结合使用Material-UI标签和react

使用Material UI标签作为链接的React Router

ReactJS Material-UI TextField更改颜色标签和下划线活动字段输入

ReactJS:如何在Material UI中更改步进标签的字体大小和marginTop?

清理重复的Material UI标签

material-ui中的透明AppBar(反应)

试图从React Material Ui覆盖AppBar的css,

如何在Material-UI中使用framer-motion?(reactjs)(@ material-ui / core)(成帧器运动)

如何在React Material UI TextField中将占位符和文本居中

使徽标与Material-UI居中对齐

ReactJS Material UI组件CSS类,澄清