如何使用相对于高度的宽度? [英] How to use width relative from height?
本文介绍了如何使用相对于高度的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要制作3:4窗口,其中3是75%的屏幕.我如何设置宽度?就像如果我有100px的高度和10000000000000px的宽度的监视器,则比我拥有75:100px的窗口.
I need to make 3:4 window, where 3 is 75% of screen. How could i set width? Like if i have 100px height and 10000000000000px width monitor, than i shold have 75:100px window.
我听说可以借助Javascript来完成.
I heard that it could be done with the help of Javascript.
推荐答案
75 *(4/3)//或任何其他比率
75*(4/3) //or any other ratio
宽度*(反比)
function getWidth(height, ratioInPercentage)
{
return height*(ratioInPercentage/100);
}
使用:
width = getWidth(100,75);
这篇关于如何使用相对于高度的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文