css 如何在Ant Design React组件中水平对齐col内容?

eivgtgni  于 8个月前  发布在  Ant Design
关注(0)|答案(2)|浏览(160)

我需要将col内容水平对齐到中心。我看了ant文档,但找不出解决方案。
我尝试的是:


的数据

egdjgwm8

egdjgwm81#

我通过向Col组件添加“type”和“align”属性来解决问题。

<Row>
    <Col span={8} style={{backgroundColor:'red'}} type="flex" align="middle" >
      Col
    </Col>
    <Col span={4} style={{backgroundColor:'blue'}}>
      Col
    </Col>
  </Row>

字符串

d5vmydt9

d5vmydt92#

我通过将CSS属性“justifyContent:center”添加到col组件来解决这个问题。

<Row>
    <Col  style={{display: 'flex', justifyContent: 'end'}}></Col>
    <Col  style={{display: 'flex', justifyContent: 'center'}}></Col>
</Row>

字符串

相关问题