To achieve the desired layout, you can utilize the CSS property
display: flex; flex-direction: column;
for the list, and then apply
flex-grow: 1; display: flex; align-items: center;
to the active element. This will cause the active element to expand and occupy all available space while vertically centering its contents.
* {margin:0;padding:0}
ul {
height: 100vh;
display: flex;
flex-direction: column;
list-style: none;
}
.active {
flex-grow: 1;
display: flex;
align-items: center;
}
<ul>
<li>foo</li>
<li>foo</li>
<li class="active">foo</li>
<li>foo</li>
<li>foo</li>
</ul>