开发者

How to use width relative from height?

I need to make 3:4 window, where 3 is 75% of scre开发者_Python百科en. How could i set width? Like if i have 100px height and 10000000000000px width monitor, than i shold have 75:100px window.

I heard that it could be done with the help of Javascript.


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

width * (reversed ratio)

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

use:

width = getWidth(100,75);


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 dimension

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜