put div above another div in bootstrap

Viewed 6312

Please I wanna know how to put a div above another div.

This is what I want before and after

enter image description here

<div class="col-md-12 container">
     <div class="col-md-12"> box1 </div>
     <div class="col-md-12"> box2 </div>
</div>
2 Answers

you have to add position-absolute class to last column and position-relative to its parent row

.col:first-of-type {
  background: red
}

.col:last-of-type {
  border: green solid
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="row position-relative">
    <div class="col"> box1 </div>
    <div class="col position-absolute"> box2 </div>
  </div>
</div>

<div class="container">
 <div class="row position-relative">
   <div class="col-md-4 box1"> box1 </div>
   <div class="col-md-4 box2 position-absolute"> box2 </div>
 </div>
</div>

        .box1 {
          width: 100%;
          height: 100px;
          background: red;
          border-radius: 25px;
          text-align: center;
        }
        .box2 {
           width: 100%;
          height: 100px;
          background: green;
          border-radius: 25px;
          top: 10px;
          text-align: center;
          left: 3px;
        }
Related