使用屏幕分辨率

时间:2015-12-30 08:18:13

标签: javascript jquery iframe

在我的网站中我使用的插件默认情况下发送iframe的内联最小高度

<iframe id="ec-frame" allowfullscreen="" style="width: 100%;min-height:659px; height:100%;" src="https://dash.evercam.io/live.view.private.widget?camera=stephens-green&amp;refresh=1&amp;api_id=&amp;api_key=&amp;rtmp=rtmp://media.evercam.io:1935/live/stephens-green?token=qoSoGPwrzLlE0ITuMa2Id_VbCGRYYGAfGJlVZVm_LfA6fcVPcHqbymbJQ9uSMSOiyYtl24i4kHr4tIm_fxfadHVNVN8mxVQ_Xps9rGsIssc=&amp;hls=https://media.evercam.io/live/stephens-green/index.m3u8?token=qoSoGPwrzLlE0ITuMa2Id_VbCGRYYGAfGJlVZVm_LfA6fcVPcHqbymbJQ9uSMSOiyYtl24i4kHr4tIm_fxfadHVNVN8mxVQ_Xps9rGsIssc=" frameborder="0" scrolling="no"></iframe>

由于这个原因,当屏幕宽度发生变化时,这个最小高度保持不变,并在iframe和下面的div之间产生很大的空间。

我试图通过调整大小功能来改变它

var currentHeight = $("#test > iframe").css('min-height');
    $(window).on('resize', function () {
      $('#test > iframe').css('min-height', "5px");
    });

但我真的不知道/找到如何编辑动态最小高度作为屏幕宽度更改,上面的函数只是将min-height设置为5px但是如果我减去某些东西

$('#test > iframe').css('min-height', currentHeight - "5px");

这根本不起作用。我想要的是随着屏幕宽度的变化改变最小高度,因为现在最小高度是659px,我想动态减去一个值,但不知道如何减去它

2 个答案:

答案 0 :(得分:0)

你好这样改变:

var currentHeight = $("#test > iframe").css('min-height');
    $(window).on('resize', function () {
      $('#test > iframe').css('min-height', $( window ).height());
    });

根据你调整窗口大小的程度动态工作

感谢

答案 1 :(得分:0)

您要从string int中减去currentHeight - "5px"

你必须做

 $('#test > iframe').css('min-height', parseInt(currentHeight) - 5);
相关问题