Mobile Safari bug on fixed positioned button after scrollTop programmatically changed…?

后端 未结 11 2208
别跟我提以往
别跟我提以往 2020-11-28 04:10

I\'m just about done a webpage but there is one bug in Mobile Safari (iPhone and iPad iOS 5.0.1) with two buttons that are fixed to the upper and lower right corners..

11条回答
  •  隐瞒了意图╮
    2020-11-28 04:39

    I had multiple links on separate fixed elements (a modal popup + fixed blackout div + normal fixed toolbar) and none of these answers were working so I had a tinker about trying variations on the same theme. Like all these suggest the key is getting elements re-rendered.

    Initially I tried adding 1px to the width of fixed elements and removing it. This did cause re-rendering, but re-rendered elements became mis-aligned with non re-rendered elements - another result of this iOS bug I suspect. The answer was to simply add to the width of the body and subtract again (or set to auto), ie:

    //jQuery will calculate the current width and then +1 to this and set it
    $('body').css('width', '+=1');
    
    //Remove width css
    setTimeout(function() {
      $('body').css('width', '');
    }, 1);
    

    If not using jquery you will need to get the current width of body +1px to it and then set the width.

提交回复
热议问题