**Background:**

I have the html:

```
<div id="container">
  <div id="page"></div>
</div>

```

Where `#container` is a fluid element that's width and height is determined by the window size.

**Question:**

What I am trying to do is programtically set the height and width of `#page` so it **occupys the largest size it can** while being constrained by:

* It must not be larger than `#container`
* It must maintain a given aspect ratio e.g. 16:9

The part I am struggling with most its making it fill the largest size it can relative to the parent div.

Any help would be much appreciated.

Thanks