I'm currently developing an application featuring a custom calendar that utilizes Flexbox for styling, with all the date logic being managed by React.
While the calendar is working perfectly fine, I've encountered a styling issue that has me stumped.
My goal is to have the week
div overflow when numerous events are added in a week, displaying a scrollbar to view all events. However, I'm facing a height problem with the day
divs as there's no fixed height on the parent (week
div) due to using flexbox with flex: 1;
to fill space. How can I ensure the children (day
divs) utilize the entire height of the overflowing parent (week
div)?
I am looking for a CSS-only solution that is compatible across different browsers.
See a Sample CodePen Here: https://codepen.io/anon/pen/jLQyxX?editors=0100
HTML:
<div class="calendar">
<div class="week">
<div class="day">6</div>
<div class="day">7</div>
<div class="day">8</div>
<div class="day">
<div>This</div>
<div>Border</div>
<div>Doesn't</div>
<div>Scale</div>
...
</div>
<div class="day">10</div>
</div>
</div>
CSS:
body {
display: flex;
flex: 1;
padding: 0;
margin: 0;
height: 100vh;
}
.calendar {
display: flex;
flex: 1;
flex-direction: column;
border: 1px solid black;
border-bottom: none;
margin: 15px;
}
.week {
display: flex;
flex: 1;
overflow: auto;
border-bottom: 1px solid black;
}
.day {
display: flex;
flex: 1;
flex-direction: column;
padding: 10px;
outline: 1px dotted red;
}