Equal the height of input with button?

Viewed 68

I have this Html:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>

<div class="d-flex">
   <div>
     <input type="text" class="input-text">
     <p class="error">error message</p>
   </div>
  <button class="cursor pl-4">apply coupon</button>
 </div>

enter image description here

If there is an error the button looks like in image!

How can equal the height of image even there is an error under input?

2 Answers

Use align-items: baseline on the according row, or align-self: baseline on the according element. Codepen.

align-self-basline or align-items-baseline would be the responsible classes in Bootstrap.

.flex {
  display: flex;
}

.reset {
  align-items: baseline;
}
<div class="flex reset">
  <div>
    <input type="text">
    <p>Error</p>
  </div>
  <button>Button</button>
</div>

You can do these types of tricks for your requirement.

<div class="d-flex">
<div>
  <input type="text" class="input-text"><button class="cursor pl-4">apply 
  coupon</button>
  <p class="error">error message</p>
</div>
Related