Amazon-Web-SDKs/Webapps/examples/Cookbook/FillScreen/
Download the Amazon Web SDKs from the SDK Download page (click the Web button).
Initial Markup and Style
The initial markup and style needed are as follows:Scaling Function
The scaling function takes two parameters: a div to be scaled and a boolean calledproportional that is used to determine whether the width and height of the div to be scaled should remain in proportion to one another, or if they can be scaled independently. The function performs these steps to determine how to scale and position the div:
- The function determines the current width and height of the div to be scaled, and the available width and height of the viewport.
- The available width is divided by the current width, and the available height is divided by the current height. The resulting values are scaling factors.
- If
proportionalis true, both scaling factors are set to be equal to the smaller of the two so that the width and height remain in proportion to each other without exceeding the visible portion of the screen. Otherwise, the sides will be scaled independently to take up as much space as possible. - The function determines translation factors so that the scaled div can be positioned so that it remains centered on the screen.
- The function updates the div’s CSS properties with the values of the scaling and translation factors.
Invoke the Scaling Function
The scaling function needs to be called when the app starts up and whenever the screen orientation changes. Once the window’s content has been fully loaded, call thefillDiv function to scale and center the div. Additionally, bind a handler that calls fillDiv to screen orientation events so that whenever a screen orientation event is detected, fillDiv is called.
Here is a sample function, initialize(), that calls fillDiv() and binds a handler to screen orientation events. The initialize() function is bound to the window’s load event:

