2015-12-30 25 views
1

在我的網站我使用的一個插件,默認情況下發送的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"); 
    }); 

有能力改變這一點,但我真的不知道/找到如何編輯此動態最小高度爲屏幕寬度的變化,上述功能剛剛設置最小高度到5px,但如果我減去東西

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

這根本不起作用。我想要的是在屏幕寬度的變化最小高度改變爲現在最小高度爲659px,我要動態減去一個值,但不知道如何減去它

+0

你減去從''string''int' currentHeight - 「爲5px」'。你必須做'$('#test> iframe')。css('min-height',parseInt(currentHeight) - 5);' –

+0

把這個放在答案裏,我想把它標記爲正確答案。 非常感謝。 –

回答

0

您從intcurrentHeight - "5px"減去string工作動態。

你要做

$('#test > iframe').css('min-height', parseInt(currentHeight) - 5); 
+0

非常感謝,它的工作真棒,parseInt是我想要的東西 –

0

你好變化是這樣的:

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

說,按照你多少調整窗口大小

感謝

+0

這不是我問 –