Home > other >  Automatic padding in Bootstrap5
Automatic padding in Bootstrap5

Time:08-18

I'm having trouble figuring out why am I getting a constant padding at the bottom of my container in Bootstrap5. I tried using align-items-center in the row to center the content, but that didn't work.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <script src="https://kit.fontawesome.com/4b6937b5e3.js" crossorigin="anonymous"></script>
    <title>Test</title>
</head>
<body>
   
    <div >
        <section >
            <div >
                <p>lorem</p>
            </div>
            <div >
                <p>lorem</p>
            </div>
            <div >
                <p>lorem</p>
            </div>
        </section>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>

CodePudding user response:

Here you go...

It's because there's a margin-bottom set to the <p> tag.

Add the following to your CSS:

p {
  margin-bottom: 0 !important;
}

See the snippet below.

p {
  margin-bottom: 0 !important;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
  <script src="https://kit.fontawesome.com/4b6937b5e3.js" crossorigin="anonymous"></script>
  <title>Test</title>
</head>

<body>

  <div >
    <section >
      <div >
        <p>lorem</p>
      </div>
      <div >
        <p>lorem</p>
      </div>
      <div >
        <p>lorem</p>
      </div>
    </section>
  </div>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>

</html>

  • Related