【问题标题】:Is there a way to use bootstrap classes in react-bootstrap?有没有办法在 react-bootstrap 中使用引导类?
【发布时间】:2019-09-11 18:08:03
【问题描述】:

我无法让引导类与 react-bootstrap 一起使用

我尝试在 react-bootstrap 中使用引导类,特别是弹性属性,但它似乎不起作用。但是在文档上,它显示了一个使用它“https://react-bootstrap.netlify.com/layout/grid/”的示例,文档也看起来很模糊,所以我去了引导程序的文档,但在那里也无济于事。

我注意到当我更改了多少个 Col(比如这个 col md={4})时,我希望一个特定的 col 元素占据这个按钮的位置,即使它应该在中心,为什么会这样?这是我的代码示例

import React from 'react';
import'./Welcome.css';
import { Button, Container, Col, Row } from 'react-bootstrap';

class Welcome extends React.Component {
  render() {
    return(
      <div className="welcome">
          <Container>
            <Row className="justify-content-center">
              <Col>
                <Button variant="primary" size="lg">Large button</Button>
              </Col>
            </Row>
          </Container>
      </div>
    );
  }
}

export default Welcome;

我对 react 也很陌生,对 react-bootstrap 更是如此,但我对 bootstrap 非常熟悉,这让我准备好只使用 CSS grid 或 flex 而不是使用 bootstrap 的网格大声笑。因此,如果有人可以帮助我,那将非常感激。

【问题讨论】:

  • 这有什么问题?用于引导的 CSS?
  • flex 属性在我尝试使用它们时不起作用,它们没有按照我期望的方式对齐元素。
  • @Tuhin 那些 JS 脚本有必要吗?我必须将它们添加到索引 html 文件中吗?我已经为 css 添加了引导 cdn 链接。对不起,我是个反应迟钝的菜鸟
  • 哦,所以 css 正在工作。你有它现在的样子的例子吗?

标签: reactjs react-bootstrap


【解决方案1】:

试试这个。

<Container>
  <Row>
    <Col md={{ order: 'last' }}>First, but last</Col>
    <Col md>Second, but unordered</Col>
    <Col md={{ order: 'first' }}>Third, but first</Col>
  </Row>
</Container>

【讨论】:

    猜你喜欢
    • 2021-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-27
    • 2013-11-03
    • 2021-10-01
    • 2019-12-12
    • 2017-02-09
    相关资源
    最近更新 更多