首页 > 解决方案 > React-Circular-Progressbar 中的文本未居中

问题描述

当我创建一个圆形进度条时,我正在努力让文本居中。

这是添加进度条和文本的代码。

<div>
  <ProgressBar
     value={80}
     text="80%"
     strokeWidth={5}
     styles={buildStyles({trailColor:"red"})}
  />

此代码是进度条的样式部分。是否可以将文本居中到进度条

const ProgressBar = styled(CircularProgressbar)`
    width: 100px;
    height: 100px;
`;

这是进度条当前的样子

标签: cssreactjsvisual-studio-codeprogress-bar

解决方案


我相信我们可以flex在这里利用。
在包含文本标签的容器上。你可以加。

display: flex;
justify-content: center;
align-items: center;

只要确保文本是应用flex我之前提到的样式的容器的直接子元素


推荐阅读