【发布时间】:2012-11-14 19:13:23
【问题描述】:
我正在根据当前视口大小在 JavaScript 中调整图像大小。没有媒体查询和其他类似的东西,一路都是 JS,也没有元素的静态大小。
所以基本上它看起来像这样:
var computedHeight = viewport.height * someRatio;
var image = goog.dom.createDom('img', {
'src': 'the.link.to.the.image',
'height': computedHeight + 'px',
'width': 'auto'
};
【问题讨论】:
-
viewport.height是这里的问题吗?试试document.body.clientHeight -
嗯...
viewport.height似乎不是问题... :)。
标签: javascript jquery google-closure-library