Topic: Dynamic Sizing

Is there a way to get Simple viewer to change size based on browser width?
For example - I'd like to have simple viewer be 100% when displayed even when viewing at 1920 wide screen or 600 wide screen?

Warm regards,
Chris Sgaraglino

Re: Dynamic Sizing

You can set a gallery's width to be a percentage (such as 100%) rather than a fixed pixel value.
However, this means that the gallery's width will be 100% of the width of its parent container.
The gallery's width will, therefore, be dynamic only if the widths of all parent containers are expressed as percentages. If there is a fixed value anywhere up the chain, then the gallery's own width will become fixed, e.g. 100% x 100% x 800px = 800px.

If you create a gallery in svBuilder-Pro with a width of 100%, the gallery will have no parent container in the generated 'index.html' file (other than the <body> tag) and the gallery's width will always span the entire width of the browser window, no matter what its size.

Alternatively, you can use JavaScript to listen out for a change in the size of the user's browser window and dynamically resize the gallery with a new width value as required. An example of this can be found in the View Vertical Resizable Gallery with Header Example in the Using a Resizable Gallery with a Header support section. You can view the source of the web page in your browser to see the code used and your can modify it to suit your own needs. The example resizes the gallery's height rather than width but the principle is the same.

Steven Speirs
SimpleViewer Support Team