The default Unity WebGL templates are a good starting place for web games, but they only run at a fixed width and height!
Note this works with Unity 2017.1 through 2019.2. I currently don't have time to get it working with the latest versions. Sorry!
With the SIMMER.io Responsive WebGL template, you can export your game so that it fits optimally in the entire browser window. If the user resizes the browser window, the Unity WebGL canvas automatically gets resized. The template also maintains the aspect ratio of your game, and adds letterboxes where appropriate.
Quick Docs:
File => Build Settings => WebGL => Add your Scenes
From Build Settings, choose Player Settings => WebGL Settings (HTML5 Icon) => Resolution and Presentation
Select "Responsive" under WebGL Templates
Build and Run
Enjoy :-D
Full documentation available at https://blog.simmer.io/responsive-webgl-template-free-in-the-unity-asset-store/
You can email the author at rocco@simmer.io if you need support.
Get free web hosting for your WebGL game or asset at: https://get.simmer.io!