react-bootstrap 卡片网格布局

 md={4} 代表每行显示4个卡片

g-2 代表卡片间的间距

import React, { useState, useEffect } from 'react';
import {
  Container,
  Row,
  Col,
  Stack,
  Form,
  Button,
  Alert,
  ToggleButtonGroup,
  ToggleButton,
  ButtonToolbar,
  ButtonGroup,
  InputGroup,
  FormControl,
  Dropdown,
  DropdownButton,
  Card,
} from 'react-bootstrap';

function LoadingButton() {
  const [value, setValue] = useState([1, 3]);

  /*
   * The second argument that will be passed to
   * `handleChange` from `ToggleButtonGroup`
   * is the SyntheticEvent object, but we are
   * not using it in this example so we will omit it.
   */
  const handleChange = (val) => setValue(val);

  return (
    <div className="m-test-wrap">
      <Row md={4} className="g-2">
        {Array.from({ length: 8 }).map((_, idx) => (
          <Col key={idx}>
            <Card>
              <Card.Body>
                <Card.Title>Card title{idx + 1}</Card.Title>
                <Card.Text>
                  This is a longer card with supporting text below as a natural
                  lead-in to additional content. This content is a little bit
                  longer.
                </Card.Text>
              </Card.Body>
            </Card>
          </Col>
        ))}
      </Row>
    </div>
  );
}

export default LoadingButton;

 

posted @ 2021-12-23 11:51  徐同保  阅读(3)  评论(0编辑  收藏  举报  来源