【问题标题】:Scale (CSS transform) iframe based on window height基于窗口高度的缩放(CSS 变换)iframe
【发布时间】: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;

非常感谢您的帮助。

【问题讨论】:

    标签: jquery css iframe scale


    【解决方案1】:

    改变 pHeight=this.adParent.height();到 pHeight=$(window).height();解决了这个问题。 div 显然总是比页面边缘高出几个像素,从而弄乱了逻辑。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-02
      • 1970-01-01
      • 2015-09-19
      • 2015-01-03
      • 2019-02-03
      • 2014-06-27
      • 2016-04-06
      • 2011-07-01
      相关资源
      最近更新 更多