look, I made an example here from scratch, maybe I can adapt your page:
In case I’m using position Absolute instead of Fixed, so the menuWrapper has its size relative to wrapper.
Instead of using height: 100%
, I’m anchoring the div
on your father, using top: 0px
and bottom: 0px
In the case of menuWrapper, I’m using margin-bottom: auto
to fill the gap between the anchor bottom: 60px
and the max-height: 240px
if the height
the wrapper is larger than 360px
advised to run the example below with full screen and resize the screen to test.
openMenu = document.getElementById("openMenu");
closeMenu = document.getElementById("closeMenu");
menu = document.getElementById("menu");
openMenu.onclick = function () {
menu.classList.remove("invisivel");
}
closeMenu.onclick = function () {
menu.classList.add("invisivel");
}
#content {
background-color: whitesmoke;
position: absolute;
padding: 0px;
margin: 0px;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
min-height: 320px;
overflow: auto;
}
.invisivel {
display: none;
}
#menu {
background-color: gainsboro;
position: absolute;
max-height: 260px;
top: 0px;
right: 0px;
left: 0px;
bottom: 60px;
margin-bottom: auto;
box-shadow: 0px 0px 10px black;
}
#rodape {
background-color: gainsboro;
position: absolute;
height: 40px;
right: 0px;
left: 0px;
bottom: 0px;
box-shadow: 0px 0px 10px black;
}
<div id="content">
<button id="openMenu">Abrir Menu</button>
<div id="menu" class="invisivel">
<button id="closeMenu">Fechar Menu</button>
</div>
<div id="rodape">
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vehicula dui in fermentum consectetur. Donec justo elit, sodales eu accumsan et, maximus eu leo. Sed pretium sapien nibh, id convallis ex scelerisque placerat. Duis pretium hendrerit elit vitae euismod. Nunc condimentum aliquet varius. Aliquam ac urna turpis. Nunc vitae elit elementum tellus malesuada feugiat id ac dolor. Etiam ultrices nibh sed placerat sollicitudin. Maecenas hendrerit gravida ex. Curabitur facilisis commodo augue, at luctus mauris egestas a. Quisque quis quam eu lorem tincidunt imperdiet sit amet non diam. Nulla facilisi. Integer et mauris quis eros ultricies ornare. Maecenas sapien nunc, condimentum ut rutrum nec, porttitor vel risus.
</p>
</div>