a.kozubenko
a.kozubenko

Reputation: 1060

Center-align a Paper component inside a div

I can not center my <Paper> inside div. Please help

I locate <Paper> and <RaisedButton> inside div and gave with css:

.timerArea {
  text-align: center;
}

For Button it works but for Paper - no.

Style for <Paper>

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

Also my JSX:

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

and result on the image enter image description here

Thanks in advance.

Upvotes: 7

Views: 23545

Answers (1)

Prakash Sharma
Prakash Sharma

Reputation: 16482

Try margin auto in paper style like this

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

Upvotes: 10

Related Questions