I've a problem with my fixed element on the bottom of my mobile device when I scroll. It looks like that the height get's re-calculated each time I scroll because the document height get's increased on mobile devices.
I think the reason is that the address bar fades out and the document viewport get's larger. I've searched a lot and tried different solutions like setting height: 100%
to html
and body
but without any success.
This is a GIF showing me scrolling on my page on my phone in chrome browser. The transparent thing a the top is the address bar:
And this is my actual code:
#wrapper {
position: fixed;
background: darkcyan;
color: #fff;
bottom: 0;
left: 0;
right: 0;
top: calc(100% - 100px);
width: 100%;
}
#bottom-element {
height: 50px;
position: fixed;
background: black;
display: block;
bottom: 0;
width: 100%;
left: 0;
right: 0;
}
#title {
text-align: center;
padding: 15px;
height: 20px;
border-bottom: 1px solid white;
}
#entries {
display: flex;
flex-direction: column;
overflow: scroll;
overflow-x: hidden;
}
.entry {
padding: 15px;
background: cadetblue;
}
<div id="wrapper">
<div id="title"></div>
<div id="entries">
<div class="entry">Test</div>
<div class="entry">Test</div>
<div class="entry">Test</div>
<div class="entry">Test</div>
<div class="entry">Test</div>
<div class="entry">Test</div>
<div class="entry">Test</div>
</div>
</div>
<div id="bottom-element"></div>
The idea is to make an expanding div from the bottom up to 80%
of the screen. So how can I fix this issue? I'm changing the top value dynamically to expand my element so if there is any solution that I can keep my layout would be nice.