How to Keep a Portrait Unity WebGL Game in Fullscreen Without Stretching It — When I first put Gem Forge Idle into fullscreen in a desktop browser, I didn’t get a larger version of the portrait game. The view became so wide and enlarged that the interface was difficult to use. The solution was to let fullscreen fill the monitor with a wrapper while keeping the playable area inside it at the game’s own portrait ratio. The space on either side is intentional. The entire interface still has to fit on the screen.
The screenshot that showed what was wrong
The mining screen was still rendering. I could see the currency row, the tutorial and some of the controls, but the layout had expanded into the shape of the monitor. The screenshot below is what I saw the moment I clicked Fullscreen: the game was still running, but the portrait layout no longer fit properly.

This is a different symptom from a game that turns black after returning from Share. If the picture is visible but cropped or stretched, start with dimensions and layout. If it looks right until you leave for another tab, look at the transition instead. I didn’t want to make one fix and assume it explained both problems.
How to Keep a Portrait Unity WebGL Game in Fullscreen Without Stretching It
I treat the fullscreen wrapper as the surface that fills the viewport. It provides the dark surround and centers the actual game area. The game surface uses the largest portrait rectangle that fits inside the available width and height. On a wide desktop monitor the limiting dimension is usually height; on a narrow device it may be width. In either case, keep the whole rectangle in view.
For a 9:16 game the sizing rule is straightforward. The game width can be no more than the available width and no more than available height multiplied by nine sixteenths. Its height is then that width multiplied by sixteen ninths. For example, if the available area is 1920 by 1080, the game can occupy about 608 by 1080 CSS pixels before any reserved controls or insets. Making the game itself 1920 by 1080 would change its aspect ratio; zooming it to cover would hide part of it.


Check both the visible box and the render target
Unity distinguishes the canvas’s CSS size from the WebGL render target’s pixel resolution. The CSS box sets the space the game takes up on screen. The render target sets how many pixels Unity draws into that space. Unity’s canvas sizing guide explains how it normally keeps the two in sync and how that behavior can be configured. I check the box and Unity’s behavior together before overriding either one. Enlarging the render target alone won’t cure a clipped interface, and a needlessly high render size can add GPU work.
If you add a Fullscreen button in your own player, tie the request to a click and account for the browser’s fullscreen change event, including the Escape route. Let the layout settle when entering and leaving. The normal page should regain its own dimensions, and game controls should remain usable. If the player is embedded in a frame, verify the frame allows fullscreen and test the actual page rather than only the standalone export.
My test is whether I can still play
I check the top HUD, the bottom controls and at least one interaction near the edge of the screen. Then I go back to the page and check it again. I also vary the window size because a layout that fits my monitor at one browser zoom can still crop on a laptop. If labels look fine but clicking them activates something in the wrong place, I haven’t finished. Pointer input is part of the test.
I accepted the fullscreen layout when the game stayed portrait and I could see and use the entire interface. A wider black surround is a much smaller problem than missing controls. You can try the resulting layout on the Gem Forge Idle browser page.

Leave a Reply