skip to Main Content

I have the following codepen snippet to work from. I can’t get the button in the left box to vertical-align to the bottom of the box. I’ve tried many different things with no luck.

https://codepen.io/rayjames/pen/LYJabMN

<html>

<head>
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-aFq/bzH65dt+w6FI2ooMVUpc+21e0SRygnTpmBvdBgSdnuTN7QbdgL+OapgHtvPp" crossorigin="anonymous">
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-qKXV1j0HvMUeCBQ+QVp7JcfGl760yU08IQ+GpUo5hlbpg51QRiuqHAJz8+BrxE/N" crossorigin="anonymous"></script>
</head>

<body>
  <div class="container">

    <div class="courses">
      <h2 class="d-flex justify-content-center text-center">Our Courses</h2>
      <div class="container">
        <div class="row">

          <div class="col-md-6 courses-container">
            <div class="drop-shadow-box">
              <span class="tpr-text-block">
                <h1 id="free-course-one-training" class="course-title">Course One Test Prep</h1>
                <h3 id="free-course-test-prep">Course One Test Prep</h3>
                <p>
                  Gives you unlimited access to our Course One Courses to help you get your certificate. Our courses cover everything you need to pass your written Cert Tests.
                </p>
              </span>
              <div class="">
                <div class="course-button-container text-center">
                  <a class="btn btn-primary btn-lg" href="#">FREE</a>
                    
                  </div>
              </div>
            </div>
          </div>

          <div class="col-md-6 courses-container">
            <div class="drop-shadow-box">
              <span class="tpr-text-block" >
                <h1 id="class-a-training" class="course-title">Course A Full Certificate</h1>
                <h3 id="class-a-eldt-certificate-plus-free-permit-test-prep">Course A Full Certificate + <br>Course One Test Prep</h3>
                <p>
                  Gives you unlimited access to all <span class="bold">REQUIRED THEORY</span> courses to get a Course A Full Certificate. Also includes unlimited access to our Course One Test Prep Courses to help you get your Cert. You will still need to go to a Cert School to do the Lab training.
                </p>
                <div class="text-center"><a class="btn btn-primary btn-lg" href="#">FREE</a></div>
              </span>
            </div>
          </div>

        </div>
      </div>
    </div>

  </div>
</body>

</html>

CSS

.courses {
  background-color: #ebf3fa;
  padding-top: 1.3rem;
  padding-bottom: 1.3rem;
}
.courses h2 {
  margin-top: 0px;
  margin-bottom: 0px;
  padding-bottom: 1.3rem;

}
.courses .drop-shadow-box {
  background-color: #fff;
  height: 100%;
  box-shadow: #ced7e0 5px 5px 15px 15px;
  padding: 2rem;
  margin: 0px 20px;
}
.courses-container {
  margin-bottom: 2rem;
}
.course-title {
  background-color: #0d314b;
  color:#fff;
  text-align:center;
}

Image of problem

I’ve tried all the different Bootstrap 5 utilities, also changing height, different displays, etc. and just can’t figure it out.

4

Answers


  1. Put the following at the end of your CSS code if you want manually change the position

    .course-button-container {margin-top: 65px;}
    
    Login or Signup to reply.
  2. I set different heights on the text area so they won’t overlap with the button just in case.

    I centered the buttons in the bottom.

    The colors are just to show me the boundaries of each div. I will remove it upon request.

    <!DOCTYPE html>
    
    <html>
    
    <head>
      <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-aFq/bzH65dt+w6FI2ooMVUpc+21e0SRygnTpmBvdBgSdnuTN7QbdgL+OapgHtvPp" crossorigin="anonymous">
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-qKXV1j0HvMUeCBQ+QVp7JcfGl760yU08IQ+GpUo5hlbpg51QRiuqHAJz8+BrxE/N" crossorigin="anonymous"></script>
    </head>
    <style>
      #mother {
        width 300px;
        position: absolute;
        height: 50px;
        text-align: center;
        bottom: 0;
        left: 40%;
      }
      
      .courses {
        background-color: #ebf3fa;
        padding-top: 1.3rem;
        padding-bottom: 1.3rem;
      }
      
      .courses h2 {
        margin-top: 0px;
        margin-bottom: 0px;
        padding-bottom: 1.3rem;
      }
      
      .courses .drop-shadow-box {
        background-color: #fff;
        height: 100%;
        box-shadow: #ced7e0 5px 5px 15px 15px;
        padding: 2rem;
        margin: 0px 20px;
      }
      
      .courses-container {
        margin-bottom: 2rem;
      }
      
      .course-title {
        background-color: #0d314b;
        color: #fff;
        text-align: center;
      }
    </style>
    
    <body>
      <div class="container">
    
        <div class="courses">
          <h2 class="d-flex justify-content-center text-center">Our Courses</h2>
          <div class="container">
            <div class="row">
    
              <div id="box" style="height: 500px;" class="col-md-6 courses-container position-relative">
                <div style="height: 500px; background-color: pink;" class="drop-shadow-box">
                  <div class="tpr-text-block" style="height: 400px; overflow: auto; ">
                    <div style="height: 120px;">
                      <h1 id="free-course-one-training" class="course-title">Course One Test Prep</h1>
                      <h3 id="free-course-test-prep">Course One Test Prep</h3>
                    </div>
                    <div style="margin: 10px;">
                      <p style="position: absolute; bottom: 10%; left: 15%; overflow: auto; height: 190px; background-color:yellow; width: 70%;">Gives you unlimited access to our Course One Courses to help you get your cert ificate. Our courses cover everything you need to pass your written Cert Tests. Gives you unlimited access to our Course One Courses to help you get your
                        certificate. Our courses cover everything you need to pass your written Cert Tests. Gives you unlimited access to our Course One Courses to help you get your certificate. Our courses cover everything you need to pass your written Cert
                        Tests.
                      </p>
                    </div>
                  </div>
    
    
                </div>
    
                <div id="mother" class="course-button-container text-center">
                  <a class="btn btn-primary btn-lg" href="#">FREE</a>
                </div>
              </div>
    
              <div style="height: 500px;" class="col-md-6 courses-container position-relative">
                <div style="height: 500px; background-color: pink;" class="drop-shadow-box">
                  <div class="tpr-text-block" style="height: 300px; overflow: auto; ">
                    <div style="height: 120px;">
                      <h1 id="free-course-one-training" class="course-title">Course One Test Prep</h1>
                      <h3 id="free-course-test-prep">Course One Test Pep</h3>
                    </div>
                    <div style="margin: 10px;">
                      <p style="position: absolute; bottom: 10%; left: 15%; overflow: auto; height: 190px; background-color:yellow; width: 70%;">Gives you unlimited access to our Course One Courses to help you get your cert ificate. Our courses cover everything you need to pass your written Cert Tests. Gives you unlimited access to our Course One Courses to help you get your
                        certificate. Our courses cover everything you need to pass your written Cert Tests. Gives you unlimited access to our Course One Courses to help you get your certificate. Our courses cover everything you need to pass your written Cert
                        Tests.
                      </p>
                    </div>
                  </div>
    
    
                </div>
    
                <div id="mother" class="course-button-container text-center">
                  <a class="btn btn-primary btn-lg" href="#">FREE</a>
    
    
    
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    
    
    </body>
    
    </html>
    Login or Signup to reply.
  3. You can do this with use Auto margins utilities. Set the drop-shadow-box to d-flex flex-column and add main div of button to mt-auto. Your code structure should be as below.

    .courses {
      background-color: #ebf3fa;
      padding-top: 1.3rem;
      padding-bottom: 1.3rem;
    }
    .courses h2 {
      margin-top: 0px;
      margin-bottom: 0px;
      padding-bottom: 1.3rem;
    
    }
    .courses .drop-shadow-box {
      background-color: #fff;
      height: 100%;
      box-shadow: #ced7e0 5px 5px 15px 15px;
      padding: 2rem;
      margin: 0px 20px;
    }
    .courses-container {
      margin-bottom: 2rem;
    }
    .course-title {
      background-color: #0d314b;
      color:#fff;
      text-align:center;
    }
    <!DOCTYPE html>
    <html>
    <head>
      <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-aFq/bzH65dt+w6FI2ooMVUpc+21e0SRygnTpmBvdBgSdnuTN7QbdgL+OapgHtvPp" crossorigin="anonymous">
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-qKXV1j0HvMUeCBQ+QVp7JcfGl760yU08IQ+GpUo5hlbpg51QRiuqHAJz8+BrxE/N" crossorigin="anonymous"></script>
    </head>
    
    <body>
      <div class="container">
        <div class="courses">
          <h2 class="text-center">Our Courses</h2>
          <div class="container">
            <div class="row">
              <div class="col-md-6 courses-container">
                <div class="drop-shadow-box d-flex flex-column">
                  <div class="tpr-text-block">
                    <h1 id="free-course-one-training" class="course-title">Course One Test Prep</h1>
                    <h3 id="free-course-test-prep">Course One Test Prep</h3>
                    <p>
                      Gives you unlimited access to our Course One Courses to help you get your certificate. Our courses cover everything you need to pass your written Cert Tests.
                    </p>
                  </div>
                    <div class="text-center mt-auto">
                      <a class="btn btn-primary btn-lg" href="#">FREE</a>
                    </div>
                </div>
              </div>
              <div class="col-md-6 courses-container">
                <div class="drop-shadow-box d-flex flex-column">
                  <div class="tpr-text-block" >
                    <h1 id="class-a-training" class="course-title">Course A Full Certificate</h1>
                    <h3 id="class-a-eldt-certificate-plus-free-permit-test-prep">Course A Full Certificate + <br>Course One Test Prep</h3>
                    <p>
                      Gives you unlimited access to all <span class="bold">REQUIRED THEORY</span> courses to get a Course A Full Certificate. Also includes unlimited access to our Course One Test Prep Courses to help you get your Cert. You will still need to go to a Cert School to do the Lab training.
                    </p>
                    </div>
                    <div class="text-center mt-auto">
                      <a class="btn btn-primary btn-lg" href="#">FREE</a>
                    </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    
    
    </body>
    
    </html>
    Login or Signup to reply.
  4. By adding Bootstrap classes d-flex flex-columnin <div class="drop-shadow-box"> and; flex-grow-1 in <span class="tpr-text-block" > elements you can get the desired output of button stick to bottom in mid to large screen sizes.

    .courses {
      background-color: #ebf3fa;
      padding-top: 1.3rem;
      padding-bottom: 1.3rem;
    }
    .courses h2 {
      margin-top: 0px;
      margin-bottom: 0px;
      padding-bottom: 1.3rem;
    
    }
    .courses .drop-shadow-box {
      background-color: #fff;
      height: 100%;
      box-shadow: #ced7e0 5px 5px 15px 15px;
      padding: 2rem;
      margin: 0px 20px;
    }
    .courses-container {
      margin-bottom: 2rem;
    }
    .course-title {
      background-color: #0d314b;
      color:#fff;
      text-align:center;
    }
    <html>
    
    <head>
      <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-aFq/bzH65dt+w6FI2ooMVUpc+21e0SRygnTpmBvdBgSdnuTN7QbdgL+OapgHtvPp" crossorigin="anonymous">
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-qKXV1j0HvMUeCBQ+QVp7JcfGl760yU08IQ+GpUo5hlbpg51QRiuqHAJz8+BrxE/N" crossorigin="anonymous"></script>
    </head>
    
    <body>
      <div class="container">
    
        <div class="courses">
          <h2 class="d-flex justify-content-center text-center">Our Courses</h2>
          <div class="container">
            <div class="row">
    
              <div class="col-md-6 courses-container">
                <div class="drop-shadow-box d-flex flex-column">
                  <span class="tpr-text-block flex-grow-1">
                    <h1 id="free-course-one-training" class="course-title">Course One Test Prep</h1>
                    <h3 id="free-course-test-prep">Course One Test Prep</h3>
                    <p>
                      Gives you unlimited access to our Course One Courses to help you get your certificate. Our courses cover everything you need to pass your written Cert Tests.
                    </p>
                  </span>
                  <div class="">
                    <div class="course-button-container text-center">
                      <a class="btn btn-primary btn-lg" href="#">FREE</a>
                        
                      </div>
                  </div>
                </div>
              </div>
    
              <div class="col-md-6 courses-container">
                <div class="drop-shadow-box d-flex flex-column">
                  <span class="tpr-text-block flex-grow-1" >
                    <h1 id="class-a-training" class="course-title">Course A Full Certificate</h1>
                    <h3 id="class-a-eldt-certificate-plus-free-permit-test-prep">Course A Full Certificate + <br>Course One Test Prep</h3>
                    <p>
                      Gives you unlimited access to all <span class="bold">REQUIRED THEORY</span> courses to get a Course A Full Certificate. Also includes unlimited access to our Course One Test Prep Courses to help you get your Cert. You will still need to go to a Cert School to do the Lab training.
                    </p>
                    <div class="text-center"><a class="btn btn-primary btn-lg" href="#">FREE</a></div>
                  </span>
                </div>
              </div>
    
            </div>
          </div>
        </div>
    
      </div>
    </body>
    
    </html>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search