I've been working on a project involving the .menu-scroll
class, which is a div within a <ul>
list. I want this div to display a scroll bar when it exceeds its height limit. However, instead of achieving this, it keeps pushing down the .menu-footer
div, causing a major layout issue on the page.
body {
margin: 0;
padding: 0;
}
.grid {
display: grid;
grid-template-columns: 300px 100px auto 100px;
grid-template-rows: 50% 50%;
background-color: gray;
height: 100vh;
}
.grid>#menu {
display: grid;
background-color: blueviolet;
text-align: center;
font-size: 30px;
grid-column-start: 1;
grid-column-end: 2;
grid-row-start: 1;
grid-row-end: 2 end;
grid-template-rows: auto 75px;
}
.grid>#posts-wrapper {
display: grid;
background-color: gray;
text-align: center;
font-size: 30px;
grid-column-start: 3;
grid-column-end: 4;
grid-template-rows: 50px auto;
grid-template-columns: auto;
}
#posts {
background-color: white;
grid-row-start: 2;
grid-row-end: 3;
}
.menu-footer {
background-color: green;
}
.menu-scroll {
display: grid;
grid-template-rows: 100px auto;
}
.menu-scroll>.cover {
background-color: yellow;
}
.menu-scroll>.menu-list {
position: sticky;
overflow: scroll;
}
.list-item {
background-color: tomato;
padding: 10px 0px;
margin-top: 5px;
}
<div class="grid" id="container">
<div class="grid-item" id="menu">
<div class="menu-scroll">
<div class="cover">cover</div>
<div class="menu-list">
<ul style="list-style: none;">
<li class="list-item">menu item</li>
<li class="list-item">menu item</li>
<li class="list-item">menu item</li>
<li class="list-item">menu item</li>
<li class="list-item">menu item</li>
<li class="list-item">menu item</li>
<li class="list-item">menu item</li>
<li class="list-item">menu item</li>
<li class="list-item">menu item</li>
<li class="list-item">menu item</li>
<li class="list-item">menu item</li>
<li class="list-item">menu item</li>
</ul>
</div>
</div>
<div class="menu-footer">sticky footer</div>
</div>
<div class="grid" id="posts-wrapper">
<div id="posts">
posts
</div>
</div>
</div>