How do I use width relative to height?

I need to make a 3: 4 window, where 3 is 75% of the screen. How could I set the width? For example, if I have a height of 100px and a monitor with a width of 10000000000000 pixels, then I have a window of 75: 100px.

I heard that it can be done with Javascript.

+2


a source to share


2 answers


75 * (4/3) // or any other relation

width * (inverse relation)

function getWidth(height, ratioInPercentage)
{
    return height*(ratioInPercentage/100);
}

      



using:

width = getWidth(100,75);

      

+2


a source


The window.resizeTo function will allow you to resize the window.
IE supports this if your page is the only tab in the window.
Chrome doesn't support this.



You can use screen.width and screen.height to get the screen size

0


a source







All Articles