css - Reactjs Bootstrap 网格

标签 css twitter-bootstrap reactjs bootstrap-4 reactstrap

我正在学习 React,但在使用 bootstrap grid/reactstrap 时遇到了一些问题。不知何故,当我使用网格系统时,我没有对齐水平列,而是垂直列。

Film.js

import React from "react";
import logo from "./ghibli.png";
import { Container, Row, Col } from "reactstrap";
import { Card, CardImg, CardText, CardBody,
  CardTitle, CardSubtitle, Button } from 'reactstrap';

const Films = props => (
  <Container>
    <Row>
      <Col md= "3">
      <Card>
        <CardImg top width="100%" src={logo} alt="Card image cap" />
        <CardBody>
          <CardTitle>{props.title}</CardTitle>
          <CardSubtitle>{props.director}</CardSubtitle>
          <CardText>{props.description}</CardText>
          <Button>Button</Button>
        </CardBody>
      </Card>
      </Col>
    </Row>
  </Container>
);

export default Films;

最佳答案

目前,一行中只有一列 (col)。

只要您将多个列添加到一行中,它们就会开始并排显示,即水平显示。

我对 reactjs 一无所知,但我怀疑以下代码可能会成功并连续生成 2 列:

const Films = props => (
<Container>
    <Row>
        <Col md= "3">
            <Card>
                <CardImg top width="100%" src={logo} alt="Card image cap" />
                <CardBody>
                    <CardTitle>{props.title}</CardTitle>
                    <CardSubtitle>{props.director}</CardSubtitle>
                    <CardText>{props.description}</CardText>
                    <Button>Button</Button>
                </CardBody>
            </Card>
        </Col>
        <Col md= "3">
            <Card>
                <CardImg top width="100%" src={logo} alt="Card image cap" />
                <CardBody>
                    <CardTitle>{props.title}</CardTitle>
                    <CardSubtitle>{props.director}</CardSubtitle>
                    <CardText>{props.description}</CardText>
                    <Button>Button</Button>
                </CardBody>
            </Card>
        </Col>
    </Row>
</Container>
);

关于css - Reactjs Bootstrap 网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48256801/

相关文章:

html - 在带有背景图像的 div 顶部画一条线

javascript - jquery中从两侧到中心的滑动效果

css - 使用bootstrap-multiselect.min.js的多选下拉列表未显示列表

css - Bootstrap 3 : place sidebar left but having it beneath the content when collapsing

reactjs - 为什么 React Hooks Axios API 调用返回两次?

html - 将 CSS 应用于页面上的特殊字符

javascript - 如何在html页面运行时默认显示模态

html - bootstrap 3.x 不显示内联的 h4 和图标

reactjs - 将 useState 与具有多个 bool 字段的对象 react

javascript - 为什么 JSON.parse(JSON.stringify(obj)) 删除 obj 的属性