【问题标题】:Center-align a Paper component inside a div居中对齐 div 内的 Paper 组件
【发布时间】:2017-07-30 16:45:37
【问题描述】:

我无法将我的<Paper> 居中在 div 中。请帮忙

我在 div 中找到 <Paper><RaisedButton> 并使用 css 给出:

.timerArea {
  text-align: center;
}

对于 Button 它有效,但对于 Paper - 没有。

<Paper> 的样式

const timeArea = {
  height: 150,
  width: 150,
  textAlign: 'center',
  rounded: true,
  paddingTop: 65,
  backgroundColor: '#76D8E3',
  opacity: 0.8
};

还有我的 JSX:

<div className={styles.timerArea}>
  <Paper style={timeArea} zDepth={1} circle>{stopWatchTime}</Paper>
  <RaisedButton onClick={buttonRole} backgroundColor={buttonColor}>{buttonName}</RaisedButton>
</div>

和图片上的结果

提前致谢。

【问题讨论】:

  • 在纸张样式中尝试“margin: auto”
  • 谢谢,它有效。请将其写为答案,我会将其标记为有帮助

标签: css reactjs material-ui


【解决方案1】:

在这样的纸张样式中尝试自动边距

const timeArea = {
  height: 150,
  width: 150,
  textAlign: 'center',
  rounded: true,
  paddingTop: 65,
  backgroundColor: '#76D8E3',
  opacity: 0.8,
  margin: auto,
};

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 2014-02-18
    • 1970-01-01
    • 2011-03-13
    • 2016-08-17
    • 1970-01-01
    相关资源
    最近更新 更多