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

Hem*_*ari 6 reactjs material-ui

如何在 CardHeader (Material-UI) 上放置标题中心?

我正在使用 Material-UI v0.18.7

这是我的代码。我尝试使用 textAlign: 'center' 到 titleStyle 道具,但这不起作用。

const myTheme = {
   cardHeaderStylePref:{
      background: 'linear-gradient(to right bottom, #430089, #82ffa1)',
      color: config.actualWhite,
      height: 30,
      padding: 0
    }
}
<Card>
     <CardHeader
            title={this.props.prefName}
            style={myTheme.cardHeaderStylePref}
            subtitleColor={myTheme.color}
            titleColor={myTheme.color}
            titleStyle={{textAlign: 'center'}}
      >
      </CardHeader>
      <CardText>
            Sample text
      </CardText>
  </Card>
Run Code Online (Sandbox Code Playgroud)

小智 6

使用 css 样式 textAlign 移动标题中心

style={{ textAlign: 'center' }}
Run Code Online (Sandbox Code Playgroud)

  • 如果我的标题中有头像怎么办?我如何将其居中对齐? (2认同)