Displaying elements other than fullscreen element (HTML5 fullscreen API)
Asked Answered
R

2

15

When I "fullscreen" an element (let's say a div), I can't get anything other elements to appear (while in fullscreen mode). Why is that happening? How can I accomplish this?

Related: Is there a way to overlay a <canvas> over a fullscreen HTML5 <video>?

Resonate answered 2/9, 2013 at 17:28 Comment(1)
Potentially relevant browser spec addition: developer.chrome.com/blog/what-is-the-top-layerSteelwork
R
26

It seems that browsers (Chrome 28, Firefox 23) set the z-index of fullscreened elements to 2147483647 (the largest 32-bit signed number). According to tests, setting the z-index of other elements to the same z-index will cause them to show, but the z-index of the fullscreened element can not be changed (it can, but the browser just ignores the value — even with !important).

Maybe the only reference I could find to this:

https://github.com/WebKit/webkit/blob/master/LayoutTests/fullscreen/full-screen-zIndex.html

Also, in Chrome dev tools:

Computed style on fullscreened element

So either set elements to the maximum z-index, or, the better solution would be to just create a container element, make it so that all elements you want to display are children of the container element, and fullscreen it.

Resonate answered 2/9, 2013 at 17:28 Comment(4)
When I tried this, it only worked in Chrome, not Firefox or IE11, though the z-index of the fullscreened element was set in all three.Consternation
same here, 3 years later.Dourine
Here's the Firefox solution: #45798713Dourine
After Chrome's update to v.69 this solution (which was also implemented by myself) won't work anymore, so a better one that seems to work fine is the Firefox one provided by Dalibor.Buttonhook
V
0

I think you can just wrap video inside div and put there also canvas and then just make div fullscreen, not just the video.

<div class="fullscreen">
    <video></video>
    <canvas></canvas>
</div>

Don't start fight with z-indexes, you'll always lose one day.

Vaporing answered 22/5 at 8:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.