如何使用 Ant Design 制作响应式网格?

D0r*_*nd0 12 css responsive-design antd angular

  • 我尝试遵循此文档,但我无法完成这项工作。
  • 我想让小屏幕的盒子分成一列,就像下面的例子一样。

在此处输入图片说明 进入 在此处输入图片说明

我是否必须使用 css insted 默认组件?

Fat*_*ani 28

使用此代码:

import 'antd/dist/antd.css';
import { Row, Col } from 'antd';

  <Row>
    <Col xs={24} xl={8}>
      One of three columns
    </Col>
    <Col xs={24} xl={8}>
      One of three columns
    </Col>
    <Col xs={24} xl={8}>
      One of three columns
    </Col>
  </Row>
Run Code Online (Sandbox Code Playgroud)

或者:

  <div className="ant-row">
    <div className="ant-col ant-col-xs-24 ant-col-xl-8">
      One of three columns
    </div>
    <div className="ant-col ant-col-xs-24 ant-col-xl-8">
      One of three columns
    </div>
    <div className="ant-col ant-col-xs-24 ant-col-xl-8">
      One of three columns
    </div>
  </div>
Run Code Online (Sandbox Code Playgroud)

  • 请注意,“xs={24}”是“xs={{ span: 24 }}”的快捷方式。因此,如果您还想根据屏幕比例更改列的顺序,您可以执行类似 `&lt;Col xs={{ span: 24, order: 2 }} xl={{ span: 8, order: 1}}&gt;` (5认同)