Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elements with position "fixed" inside an iframe are not rendering in Safari

We are experiencing a problem where elements with position: fixed; within an iframe are not being rendered correctly. We only noticed this on macOS in Safari.

Here is how it should look:

enter image description here

Here is what Safari on macOS looks like (on page load):

enter image description here

On page load the top and bottom bars are not visible. They are in the DOM taking up space and can be clicked but they have not been "rendered" by the browser. As you can see in the image above the bars appear as white space.

If we force a redraw via JS, CSS or by resizing the browser the bars will appear. We are however not looking for a solution for how to force redraw. Our question is why is this happening in the first place?

You can find a live example here:

https://testing.enuvo.ch/user/collect/#collector#/user/overlay

PS: It does not always happen. Sometimes, when resizing the browser and trying again, it will display correctly. We hope you can reproduce the problem.

like image 803
Bruffstar Avatar asked Apr 06 '17 16:04

Bruffstar


People also ask

Why my position fixed is not working?

Position fixed doesn't work with transform CSS property. It happens because transform creates a new coordinate system and your position: fixed element becomes fixed to that transformed element. To fix the problem you can remove transform CSS property from the parent element.

Does Safari support iframes?

sandbox attribute for iframes is Fully Supported on Safari 7.1, which means that any user who'd be accessing your page through Safari 7.1 can see it perfectly.


1 Answers

So there are some glitches with position: fixed and z-index. Some of the older browsers treat it a bit differently and deal with stacking contexts in a different way.

After a bit of trial and error I've managed to get it working with injected stylesheet by adding:

#ol-main-header,
#cl-footer {
  -webkit-transform: translateZ(0);
}

Also you should be able to remove the unnecesarry z-index: 99999. Hope that helps.

like image 168
T.Chmelevskij Avatar answered Sep 22 '22 11:09

T.Chmelevskij