If you change your .mainContainer
CSS so that the height is auto
. Now the list will not move up, but only will move down as you wanted as the height is flexible depending on the content:
.mainContainer {
width: 100vw;
height: auto;
display: flex;
align-items: center;
justify-content: center;
}
Also, if you change the .content
CSS so that the min-height
is auto
it seems to look nicer when there are fewer li
elements:
.content {
min-height: auto;
width: 300px;
border-radius: 5px;
background: #f2f2f2;
border: 1px #ccc solid;
}
Updated (again) Fiddle, try to add more li
elements
If your looking for the list to stay in position, but when more elements are added to have a scroll but still be fixed see this other Fiddle