Bootstrap 容器引导颜色

7bsow1i6  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(1)|浏览(155)

最近,我用 Bootstrap ,使我的网站响应,只要我把容器,它添加了一个边距,它有一个白色的颜色,它不采取的颜色其余的背景,我怎么能解决这个问题?

<!-- Bootstrap-4 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">

<!-- Body -->
<div class="container">
  <section class="lndForm">
    <div class="containerform">
      <div class="row">
        <div class="col-md-6" id="div2">
          <div class="textCTA">
            <h2 class="title"> Ajudando pessoas comuns a passar na redação ENEM </h2>
            <form action="https://formsubmit.co/rodrigoriosn3@gmail.com" method="POST">
              <input type="hidden" name="_captcha" value="false">
              <input type="hidden" name="_next" value="http://margarethredacoes.com.br/">
              <label for="nome">Nome</label> <br>
              <input type="text" name="NOME" id="" required> <br>
              <label for="email" required>Email</label> <br>
              <input type="email" name="E-MAIL" id="" required> <br>
              <label for="telefone">Telefone</label> <br>
              <input type="text" name="TELEFONE" id="" required>
              <button type="submit" onclick="alerta()">Continuar</button>
            </form>
          </div>
        </div>
        <div class="col-md-6" id="div1">
          <div class="containerimage">
            <img src="/Imagens/professora.png" alt="">
          </div>
        </div>
      </div>
    </div>
  </section>
</div>
avwztpqn

avwztpqn1#

从你的问题中还不清楚你是如何写你的css的。所以我试着用我自己的方式向你解释。
当你设置背景颜色到任何部分总是尝试设置它在父html标签上像我设置这个部分的背景颜色在部分标签<section class="bg-success">然后如果你需要从左边和右边的边距你可以使用container类在子块元素像这样<div class="container"> .

<section class="bg-success">
  <div class="container">
    <!-- your content here -->
    <p class="text-light">
      Lorem ipsum, dolor sit amet consectetur adipisicing elit.
    </p>
  </div>
</section>

但是如果你把container类设置为section<section class="container">,并在子块元素<div class="bg-success">中设置背景颜色,那么你将只得到container内部的背景,左右两边都是白色边距。

<section class="container">
      <div class="bg-success">
        <!-- your content here -->
        <p class="text-light">
          Lorem ipsum, dolor sit amet consectetur adipisicing elit.
        </p>
      </div>
    </section>

相关问题