Look, I've made an example here from scratch, I might be able to adapt your page:
In case I'm using position absolute instead of fixed, so that the wrapper menu is relative to the wrapper.
Instead of using height: 100%
, I am anchoring div
in your parent, using top: 0px
and bottom: 0px
In the case of the wrapper menu, I'm using% wc to fill the difference between the margin-bottom: auto
anchor and the bottom: 60px
if the max-height: 240px
of the wrapper is greater than height
I recommend running the example below with full screen and resizing 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>