【问题标题】:why are my rows and columns slightly to the left with react-bootstrap?为什么我的行和列在 react-bootstrap 的左侧略微偏左?
【发布时间】:2021-01-19 01:19:37
【问题描述】:

我正在使用 react-bootstrap 使我的网站具有响应性。我之前使用过 react-bootstrap 并且总是遇到这个问题:在设置我的行和列时,它们稍微向左而不是居中,好像没有边距一样。我已经使用类名将整行居中,但它并没有像我想要的那样响应。这是我的代码,还没有 css 发生

const Projects = () => {
      return (
        <div className='Projects' >
          <Row className='mt-5 pt-5 my-auto'>

            <Col lg={4}> <img src={image} alt=""/> </Col>
   
            <Col lg={4}> <img src={image} alt=""/> </Col>
            
            <Col lg={4}> <img src={image} alt=""/> </Col>
  

          </Row>
        </div>
      );
    }

Here's what it looks like 稍微靠左,右边有一些空间。任何帮助表示赞赏!

【问题讨论】:

    标签: css reactjs react-bootstrap


    【解决方案1】:

    Bootstrap 网格必须包含在 &lt;Container&gt; 中:

    const Projects = () => {
          return (
            <Container className='Projects' >
              <Row className='mt-5 pt-5 my-auto'>
    
                <Col lg={4}> <img src={image} alt=""/> </Col>
       
                <Col lg={4}> <img src={image} alt=""/> </Col>
                
                <Col lg={4}> <img src={image} alt=""/> </Col>
      
    
              </Row>
            </Container>
          );
        }
    

    【讨论】:

    • 感谢您的回复!它看起来确实好一点,但还是有点不平衡,这让我抓狂
    猜你喜欢
    • 1970-01-01
    • 2018-02-19
    • 1970-01-01
    • 2022-08-17
    • 1970-01-01
    • 1970-01-01
    • 2011-11-05
    • 2018-06-09
    • 2017-05-03
    相关资源
    最近更新 更多