Bootstrap 容器正在浏览页面视图

owfi6suc  于 2023-03-06  发布在  Bootstrap
关注(0)|答案(1)|浏览(161)

由于我不是CSS的粉丝,我决定在我的小项目中使用Bootstrap。但是,其中一个容器正在浏览页面,我不明白为什么。

<!-- 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>

我的确切意思是:

尝试设置不同的边距和填充仍然没有我想要的结果。我不能找到我的答案在谷歌也。
另外一个问题,为什么btn-block不起作用?我不得不使用w-100。

a0x5cqrl

a0x5cqrl1#

在Bootstrap中,行属于容器:
容器是Bootstrap中最基本的布局元素,在使用默认网格系统时是必需的。

<!-- 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>

相关问题