【发布时间】:2015-05-08 02:58:19
【问题描述】:
我正在尝试修改现有的工作 JS (https://github.com/mattnish/rad) 以按宽度缩放到按高度缩放,而不是进行逻辑转换,div 会随着窗口大小的变化而继续增长,所以源代码继续缩放以适应,从不匹配窗口。宽度缩放仍然适用于正确的逻辑。我应该用什么来代替 div 高度,或者我只是在数学上做错了什么?
小提琴是https://jsfiddle.net/0jm4a7ob/17/,但是缩放代码在小提琴中不起作用(即使是原始JS,但作为自己的文件) 我添加的代码是:
var pHeight=this.adParent.height();
pHeight-=parseInt(this.adParent.parent().css("marginTop").replace("px",""))+parseInt(this.adParent.parent().css("marginBottom").replace("px",""));
var newScale=pHeight/this.adHeight-0.001;
var newWidth=pHeight*this.adWidth/this.adHeight;
var newHeight=this.adHeight*newWidth/this.adWidth;
非常感谢您的帮助。
【问题讨论】: