Scale a fixed-size viewport
Make the game screen into one fixed-size plate such as 1600×900, and grow or reduce the overall with transform: scale according to the screen size, so that the placement on PC, tablet, and phone is the same.
- Category
- CSS & layout
Technical terms · Fixed-resolution stage scaling (letterbox) · transform: scale() + transform-origin · Aspect-fit (min of width / height ratio) · ResizeObserver