Is it possible to set a vertical scroll on a container with unknown height using flexbox?
I can not use max-height
as it will limit the hei
flex
has some short comings/bugs/flaws, or what ever to call them, and need an inner absolute element to force the scroll.
html, body{
height: 100%;
overflow: hidden;
}
.list{
display: flex;
flex-direction: column;
height: 100%;
}
header {
flex: 0;
}
.vertical {
flex: 1;
position: relative;
}
.scroll {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: auto;
}
<div class="list flex-vertical">
<header>Some header</header>
<div class="vertical">
<ul class="scroll">
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item4</li>
<li>Item5</li>
<li>Item6</li>
<li>Item7</li>
<li>Item8</li>
<li>Item9</li>
<li>Item10</li>
<li>Item11</li>
<li>Item12</li>
<li>Item13</li>
<li>Item14</li>
<li>Item15</li>
<li>Item16</li>
<li>Item17</li>
<li>Item18</li>
<li>Item19</li>
<li>Item20</li>
<li>Item21</li>
<li>Item22</li>
<li>Item23</li>
<li>Item24</li>
<li>Item25</li>
<li>Item26</li>
<li>Item27</li>
<li>Item28</li>
</ul>
</div>
</div>