[英]change inline min-height with screen resolution
in my website i am using a plugin which is by default sending inline min-height of 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&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>
due to this, when screen width changes this min-height remains same and causing a lot of space between the iframe and lower div. 因此,当屏幕宽度更改时,此最小高度保持不变,并在iframe和下div之间造成大量空间。
I am trying to change this with on resize function 我正在尝试通过调整大小功能来改变这一点
var currentHeight = $("#test > iframe").css('min-height');
$(window).on('resize', function () {
$('#test > iframe').css('min-height', "5px");
});
but i really dont know/find how to edit this for dynamic min-height as screen width changes, the above function just set min-height to 5px but if i subtract something as 但是我真的不知道/不知道如何随着屏幕宽度的变化来编辑动态最小高度,上述功能只是将最小高度设置为5px,但是如果我减去一些作为
$('#test > iframe').css('min-height', currentHeight - "5px");
this doesn't work at all. 这根本不起作用。 what i want is to change min-height with the change in screen width as now min-height is at 659px, i want to subtract a value dynamically but dont know how to subtract it 我想要的是随着屏幕宽度的变化来更改最小高度,因为现在最小高度为659px,我想动态减去一个值,但不知道如何减去它
Hello change like this : 你好这样的变化:
var currentHeight = $("#test > iframe").css('min-height');
$(window).on('resize', function () {
$('#test > iframe').css('min-height', $( window ).height());
});
that work dynamically as per how much you resize the window 根据您调整窗口大小动态地工作
thanks 谢谢
You are subtracting string
from int
currentHeight - "5px"
. 您正在从int
currentHeight - "5px"
中减去string
。
You have to do 你必须做
$('#test > iframe').css('min-height', parseInt(currentHeight) - 5);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.