在我的网站中,我使用的插件默认发送 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&refresh=1&api_id=&api_key=&rtmp=rtmp://media.evercam.io:1935/live/stephens-green?token=qoSoGPwrzLlE0ITuMa2Id_VbCGRYYGAfGJlVZVm_LfA6fcVPcHqbymbJQ9uSMSOiyYtl24i4kHr4tIm_fxfadHVNVN8mxVQ_Xps9rGsIssc=&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");
});
但我真的不知道/不知道如何在屏幕宽度变化时编辑动态最小高度,上面的函数只是将最小高度设置为 5px 但如果我减去一些东西
$('#test > iframe').css('min-height', currentHeight - "5px");
这根本不起作用。我想要的是随着屏幕宽度的变化来改变最小高度,因为现在最小高度是659px,我想动态减去一个值,但不知道如何减去它
最佳答案
您正在从 int
currentHeight - "5px"
中减去 string
。
你必须做
$('#test > iframe').css('min-height', parseInt(currentHeight) - 5);
关于javascript - 根据屏幕分辨率更改内联最小高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34525554/