Search code examples
bootstrap-4bootstrap-studio

Bootstrap Studio: Placing a jumbotron in the center of the page


So here is what I want What I want

And here is what I get... I tried adding rows/columns but they only affect the movement from top to bottom, I used to be able to place a column/row on the left side of the jumbotron but now I can't anymore... Is there something that I'm missing with columns and rows? enter image description here

Here is my code:

<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Mailsafe</title>
    <link rel="stylesheet" href="bootstrap.min.css" />
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Bitter:400,700" />
    <link rel="stylesheet" href="Header-Dark.css" />
    <link rel="stylesheet" href="styles.css" />
</head>

<body id="hero" style="background-color:#004878;">
    <section class="d-flex mse spacer" id="hero">
        <div id="hero-top"></div>
        <div id="hero-bottom"></div>
    </section>
    <div>
        <div class="container">
            <div class="row">
                <div class="col">
                    <div class="jumbotron flex-grow-0 flex-shrink-1" id="gateway">
                        <h1 class="text-center">Company Name</h1>
                        <p class="text-center"><br />Company blah blah<br />company blah blah blah.<br /><br /></p>
                        <p class="text-center"><a class="btn btn-primary" href="#" style="  width:673px;
">Get Started →</a></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>


Solution

  • Add 100% height on the body and html and d-flex h-100 align-items-centerclasses on the container's wrapping div. Additionally remove width from the Get started anchor and add display block to it.

    html,
    body {
      height: 100%;
      margin: 0;
    }
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    
    <body id="hero" style="background-color:#004878;">
      <section class="d-flex mse spacer" id="hero">
        <div id="hero-top"></div>
        <div id="hero-bottom"></div>
      </section>
      <div class="d-flex h-100 align-items-center">
        <div class="container">
          <div class="row">
            <div class="col">
              <div class="jumbotron flex-grow-0 flex-shrink-1" id="gateway">
                <h1 class="text-center">Company Name</h1>
                <p class="text-center"><br />Company blah blah<br />company blah blah blah.<br /><br /></p>
                <p class="text-center"><a class="btn btn-primary" href="#" style="display:block;">Get Started →</a></p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </body>