css - Fixed position div causes page to be truncated in less common mobile browsers -


i know there many similar issues, different have encountered before, thought describe bug here, , offer solution - , ask if else has better solution or can shed light on cause of weird issue.

the bug:

in page has div in position:fixed style, in less common mobile browsers, e.g. star safari, du browser, tint browser - page loads expected, , div fixed expected, if page height greater 1500px, bottom of page truncated - complete white curtain. can still scroll bottom, it's white, 0 content. this bug not happen in more common browsers chrome, firefox, opera, safari etc..

here's screen shot phone (htc m8 - tint browser) - reproduced bug on samsung s5.

tint browser bug

there many reasons might want fixed div, in case menu button can follow viewport, visitor doesn't have scroll top menu.

i have posted semi-solution bellow, not mark correct week, else can offer better solution.

tim

the reason call "semi-solution" 2 reasons:

1) not keep div fixed, elegantly move div after scroll event.

2) while doesn't cause page truncate permanently, flash 'curtain' during opacity transitions. weird, right?

edit: should mention solution looks great in common browsers (chrom, safari etc...), flashing curtain apply browsers otherwise truncated fixed position div, although isn't pretty in less common browsers, it's still better alternative, , minor compromise in style more common browsers.

this code menu button example, adapt own needs.

html example

<body onscroll="menubutton()">     <div style="height:2000px; border: thick dotted green; width:90vw; background-color:#131313"></div>     <div id="menubutton">         <div class="image"></div>     </div> </body> 

css

#menubutton {     position: absolute;     top:25px;     left: 25px;     opacity: 1;     z-index: 1001;     transition: opacity .4s ease-in-out;     -moz-transition: opacity .4s ease-in-out;     -webkit-transition: opacity .4s ease-in-out; }  .image {     width:50px;     height:50px;     background-color:red; } 

javascript

function menubutton() {     settimeout(function () {         var button = document.getelementbyid("menubutton").style;         var pos = document.documentelement.scrolltop || document.body.scrolltop;         var newpos = pos + 25 + 'px'; // offset start value of div top position.         button.opacity = 0;         settimeout(function () {             button.top = newpos;                     settimeout(function () {                         button.opacity = 1;                     }, 500);         }, 500);     }, 800); } 

and here jsfiddle


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -