0

According to bootstrap documentation I should be able to vertically align something inside of a column by using the align-middle class. I have written this code in typescript, react-bootstrap and align-middle is not working for me.

    const Style = styled.div<StyledProps>`
      .fixed {
        background-image: url(${props => props.image? props.image : '../img/matrix.jpg'});
        background-repeat: none;
        background-attachment: fixed;
        background-size: cover;
        min-height: 400px;
      }
    `;
    
    export const FixedBackground = () => {return (
      <Style image={matrix}>
        <Container>
          <Row className="text-light py-5 align-items-center align-middle align-items-center">
            <Col className="col col-lg-12 col-md-12 text-center fixed align-middle align-items-center">
              <h1 className="align-middle">Advance to the next level</h1>
            </Col>
          </Row>
        </Container>
      </Style>
    )};

I want the h1 tag to be in the vertical center of the image... but it appears on the top. I also googled and found this thread but the suggestion of adding align-items-center doesn't work for me.

Knows Not Much
  • 30,395
  • 60
  • 197
  • 373

1 Answers1

1

Add class d-flex with your Col to make it display:flex. You can use class justify-content-centre to center your content horizontally. Use class align-items-center to center your content vertically.

Ronak Lalwani
  • 376
  • 2
  • 9