Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bootstrap container is going over the page view

As I am not a fan of CSS decided to use Bootstrap to my little project. However, one of the container is going over page view and I cannot understand why.

<!-- STYLE -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">

<nav class="navbar bg-primary">
  <div class="container text-white justify-content-center">
    <h1>Weather Dashboard</h1>
  </div>
</nav>

<main class="">
  <div class="row">
    <div class="col-sm-3 bg-secondary">
      <!-- SIDE BAR ?-->
      <div class="row">
        <!-- side bar first row -->
        <div class="container">
          <h4>Search for a City:</h4>
          <form>
            <div class="form-group">
              <input type="text" class="form-control" id="city-name-search" placeholder="Enter city name...">
            </div>
            <button type="submit" class="btn btn-primary w-100">Submit</button>
          </form>
        </div>
      </div>

      <div class="row">
        <!-- side bar second row -->
        <div class="container-fluid">
          two
        </div>
      </div>
    </div>

    <div class="bg-danger col-9">
      <!-- MAIN CONTENT -->
      <div class="row">
        <div class="container-fluid lh-1 border border-dark">
          <h2>City name (dd/mm/yyy)</h2>
          <p>Temp:</p>
          <p>Wind:</p>
          <p>Humidity:</p>
        </div>
      </div>

      <div class="row">
        <div class="container-fluid">
          <h3>5-Day Forecast</h3>
        </div>
      </div>
    </div>
  </div>

</main>

<!-- SCRIPTS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>

Picture of what I exactly mean:

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Tried setting different margin and padding still without result I want. I can’t find my answer in google either.

Additional question, why btn-block doesn’t work? I had to use w-100.

>Solution :

In Bootstrap, rows belong within containers:

Containers are the most basic layout element in Bootstrap and are
required when using our default grid system.

<!-- STYLE -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">

<nav class="navbar bg-primary">
  <div class="container text-white justify-content-center">
    <h1>Weather Dashboard</h1>
  </div>
</nav>

<main class="container-fluid">
  <div class="row">
    <div class="col-sm-3 bg-secondary">
      <!-- SIDE BAR ?-->
      <div class="row">
        <!-- side bar first row -->
        <div class="container">
          <h4>Search for a City:</h4>
          <form>
            <div class="form-group">
              <input type="text" class="form-control" id="city-name-search" placeholder="Enter city name...">
            </div>
            <button type="submit" class="btn btn-primary w-100">Submit</button>
          </form>
        </div>
      </div>

      <div class="row">
        <!-- side bar second row -->
        <div class="container-fluid">
          two
        </div>
      </div>
    </div>

    <div class="bg-danger col-9">
      <!-- MAIN CONTENT -->
      <div class="row">
        <div class="container-fluid lh-1 border border-dark">
          <h2>City name (dd/mm/yyy)</h2>
          <p>Temp:</p>
          <p>Wind:</p>
          <p>Humidity:</p>
        </div>
      </div>

      <div class="row">
        <div class="container-fluid">
          <h3>5-Day Forecast</h3>
        </div>
      </div>
    </div>
  </div>

</main>

<!-- SCRIPTS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading