简体   繁体   English

将文字与中间的图标对齐

[英]align text with the icon in center

I have following code for a component 我有一个组件的以下代码

      <div>
        <icon
          HeaderText={<p className="text-center">{translations.show}</p>}
          FooterText={<p>{translations.hide}</p>}
          color={this.concept}
          className="u-pv--sm"
        >
          {getList}
        </icon>
      </div>

When i apply the existing text-center class it only moves the text to center and not the icon. 当我应用现有的文本中心类时,它仅将文本移动到中心而不是图标。 Is there any way i could move both in center without making any changes to text-center class and possibly not using inline style? 我有什么办法可以在不更改text-center类的情况下既可以居中移动又可以不使用内联样式?

Thanks 谢谢

What happens when you apply text-center to the div instead of the <p> . text-center而不是<p>应用于div时会发生什么。

I mean like this: 我的意思是这样的:

<div class="text-center">
        <icon
          HeaderText={<p>{translations.show}</p>}
          FooterText={<p>{translations.hide}</p>}
          color={this.concept}
          className="u-pv--sm"
        >
          {getList}
        </icon>
      </div>

Have you tried using justify content? 您是否尝试过使用证明内容?

<div class="d-flex justify-content-center">
    <icon
      HeaderText={<p>{translations.show}</p>}
      FooterText={<p>{translations.hide}</p>}
      color={this.concept}
      className="u-pv--sm"
    >
      {getList}
    </icon>
  </div>

When text-center doesn't work for me, this usually works 如果文本中心对我不起作用,通常可以

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

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