【发布时间】:2017-03-19 16:41:41
【问题描述】:
假设我有一个位于离子内容之上的 div。我正在尝试通过获取设备的宽度并计算它来设置 div 的高度,以使纵横比为 16:9,就像 youtube 应用程序一样。但是,我不知道如何使用 css 来实现它。现在,这就是我所拥有的。
div {
width: auto;
max-height: 40%; <-- how to set this height so that it is 16:9
background: black;
div.img {
width: 360px;
max-height: 202.5px;
}
我想要什么:
【问题讨论】:
-
16:9 也就是说你需要
heightwidth这样的比例? -
div 16 的宽度(屏幕宽度的 100%):div 9 的高度
-
就拿我的答案吧,css解决了
标签: javascript html css typescript ionic-framework