0

Maybe this is a general question, but please help me. I have a class in CSS which I often use in my HTML, e.g.

.boxBooking {
  width: 14.28%;
}
<div class="boxBooking">
  ....
</div>

<div class="boxBooking">
  test<br/> test
  <br/>
</div>

<div class="boxBooking">
  a<br/> b
  <br/> c
  <br/> d
  <br/>
</div>

If I set height property in CSS, then the height will not dynamically follow the "highest" in my HTML.

I want, which one is the "highest" will be the others default height property, even if the others have no content. Is this possible and how can I do this.

Roy Scheffers
  • 3,832
  • 11
  • 31
  • 36

3 Answers3

0

You can use flex-box for this. Just place a wrapper div around the boxBooking divs and set it to display: flex. Then each of the divs in it - set to flex-gorw: 1 and they will all take the same space.

Note I just put a red border around them to show they are all the same height.

.boxBooking-wrapper  {
display: flex;
}


.boxBooking{
  width:14.28%;
  flex-grow:1;
  border: solid 1px red;
}
<div class="boxBooking-wrapper">
  <div class="boxBooking">
  </div>

<div class="boxBooking">
  test<br/>
  test<br/>
</div>

  <div class="boxBooking">
    a<br/>
    b<br/>
    c<br/>
    d<br/>
  </div>
</div>
gavgrif
  • 15,194
  • 2
  • 25
  • 27
0

You can try using flexbox check blow updated snippet

.main {
  display: flex;
}

.boxBooking {
  width: 100%;
  border: 1px solid red;
  margin: 2px;
}
<div class="main">
  <div class="boxBooking">

  </div>

  <div class="boxBooking">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
    survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
  </div>

  <div class="boxBooking">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry.
  </div>
</div>
Vikas Jadhav
  • 4,597
  • 2
  • 19
  • 37
0

Use display:table/table-cell

.boxBooking-wrapper  {
  display:table;
  
}


.boxBooking{
  width:14.28%;
  display:table-cell;
  border: 1px solid black;
}
<div class="boxBooking-wrapper">
  <div class="boxBooking">
  </div>

<div class="boxBooking">
  test<br/>
  test<br/>
</div>

  <div class="boxBooking">
    a<br/>
    b<br/>
    c<br/>
    d<br/>
  </div>
</div>
Sooriya Dasanayake
  • 1,106
  • 1
  • 7
  • 14