REQUIREMENT :
- I have an action bar with button called
Next Scale, which is ofposition: stickyandbottom: 0in mobile view. - I want this HTML element to stick to the bottom of the viewport as we scroll and stays to the bottom when it is out of view.
PROBLEM :
In the given GIF image below, the actions bar and the
Next scalebutton goes hidden below the mobile navigation pane, while the same sticky feature requirement works as expected in desktop.If i scroll to the end of the page and scroll back above, the actions bar work as expected and stays sticky above the navigation pane. But when i reach to the top, it gets hidden again.
QUESTION :
- How to make sure the sticky element's
bottomcalculation starts above the mobile navigation pane, so that the element is always visible ? - If this is the default behaviour in mobile, then how to solve this ?
CODEPEN LINK : ( Please open the "full page view link" in mobile to reproduce issue )
STICKY html issue codepen link ( full page view )
DEMO HD YOUTUBE LINK :
DEMO :
UPDATE (8/7/22):
- Found out that this issue is due to
dynamic viewport heightchanges in mobile browsers ( Ref: https://stackoverflow.com/a/72245072/4894872 ). - Along with the layout styles that i have used in the code. The layout component styles are given below :
.layout {
display: block;
position: relative;
height: 100vh;
width: 100vw;
min-height: 100%;
overflow-x: hidden;
}
Based on CANIUSE, the new viewport unit options like
dvh,lvh,svhare currently available only for firefox and safari. (At the time of writing this update. ( Ref: https://caniuse.com/viewport-unit-variants , FIREFOX DEMO: https://youtube.com/shorts/y-q2V3Ps0VQ?feature=share , CHROME DEMO: https://youtube.com/shorts/V2gkdwtbDh8?feature=share )The closest recreation of the original code is available in this codepen (NOTE: Please open in mobile browsers like Chrome / firefox / edge )-> https://codepen.io/sparkeplug/pen/WNzwerE ( View in DEBUG MODE ).
CODEPEN DEMO VIDEO IN MOBILE: https://youtube.com/shorts/wTrPIruyERs?feature=share
In the above codepen demo, the
safe-area-insetvalues usingenv()in css doesn't fix the issue.Recap of the original issue in mobile devices video : https://youtube.com/shorts/lIEfHgYkSjQ?feature=share
QUESTION UPDATED :
- How to fix the sticky elements with
bottom: 0not getting obscured by devices navbar due to dynamic viewport height changes, Without using the new viewport unitdvh?

