简体   繁体   English

React Component 中 props 的样式 position

[英]Styling position of props in React Component

How to style 'Text' to blue circle having following code:如何将“文本”设置为具有以下代码的蓝色圆圈:

type WizardCircleProps = {
  wizardCircleContent: React.ReactNode;
};

const circleStyle = {
  background: '${props => props.theme.palette.active}',
  borderRadius: '50px',
  width: '32px',
  height: '32px',
  margin: '18px',
};

export class WizardCircle extends Component<WizardCircleProps> {

  render() {
    const { wizardCircleContent } = this.props;

  return (
    <div style={circleStyle}>
      **{wizardCircleContent}**
    </div>
  );
  }
}

Gave me:给我:

在此处输入图像描述

My goal is to have:我的目标是:

在此处输入图像描述

I just want to center the 'Text' or similar text to the center of circle.我只想将“文本”或类似文本居中到圆心。

It's a css problem.这是一个css问题。

Pay attention to line-height and text-align .注意line-heighttext-align

 #round { background: #00f; border-radius: 50px; color: white; width: 32px; height: 32px; font-size: 20px; line-height: 32px; text-align: center; };
 <div id="round">1</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM