0

I am making a daily calendar, and each day has 12 time slots. The 12 time slots fill the screen vertically and should be of equal height -- whether they have content or not. However, when a cell has some text content, its height grows unnecessarily. Why is that? I could programatically set the height of the cells but would prefer a CSS solution.

Here is the code (and here is a CodePen https://codepen.io/alpo22/pen/YzYqpWZ?editors=1100):

.appointment-cells {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: calc(100vh - 15px);
}

.appointment-cell {
  border: 1px dashed #ccc;
  border-radius: 4px;
  flex: 1 1 auto;
  overflow: hidden;
  max-height: 100px;
  min-height: 25px;
  background-color: #fafafa;
}
<div class="appointment-cells">
  <div class="appointment-cell"></div>
  <div class="appointment-cell">why is this cell taller?</div>
  <div class="appointment-cell"></div>
  <div class="appointment-cell"></div>
  <div class="appointment-cell"></div>
  <div class="appointment-cell"></div>
  <div class="appointment-cell"></div>
  <div class="appointment-cell"></div>
  <div class="appointment-cell"></div>
  <div class="appointment-cell"></div>
  <div class="appointment-cell"></div>
  <div class="appointment-cell"></div>
</div>

Thank you.

Alan P.
  • 2,898
  • 6
  • 28
  • 52

0 Answers0