简体   繁体   English

如何在网页中缩小不需要的空白区域?

[英]How to make unwanted white space shrink in webpage?

I have a page contains two vertically divs. 我有一个页面包含两个垂直div。 First div contains iframe holder and the second random contents. 第一个div包含iframe持有者和第二个随机内容。 The iframe can be less or more in height (has dynamic height). iframe的高度可以更小或更多(具有动态高度)。

The problem when the iframe holder decrease in height, that causes unwanted white space between the iframe holder and the second div below it. 当iframe持有者的高度降低时,问题会导致iframe持有者与其下方的第二个div之间产生不必要的空白 This problem occurs in chrome only, IE & FF are working fine. 仅在chrome中出现此问题,IE和FF工作正常。

How can I make this white space shrinks when the iframe decrease in height? 当iframe降低高度时,如何使这个空白区域收缩

Here is my page 这是我的页面

The iframe holder div contains the menu tabs, the second div below it contains a 3 columns of contents. iframe holder div包含菜单选项卡,它下面的第二个div包含3列内容。


Update #1: 更新#1:

Screenshot one: 截图一:

在此输入图像描述

Screenshot two: 截图二:

在此输入图像描述

If you add jQuery to dual_core.html then the following script should help. 如果您将jQuery添加到dual_core.html,那么以下脚本应该有所帮助。 You can do the equivalent without jQuery, but I had something similar made so I just replaced with your selector IDs. 你可以在没有jQuery的情况下做同等的事情,但我有类似的东西,所以我只用你的选择器ID替换。

$('#dualcore_servers_menu_wrapper1 a').click(function(){
    menuHeight = $('#dualcore_servers_menu_wrapper1').height();
    contentHeight = $('#dualcore_servers_content_wrapper1').height();
    $('iframe[name="dservers"]').height( (menuHeight + contentHeight) + 'px');
});

Its not exact, the $('iframe[name="dservers"]') selector will need to change, but its the general idea. 不完全是,$('iframe [name =“dservers”]')选择器需要改变,但它的一般想法。 Hope this helps! 希望这可以帮助!

The problem is your <iframe> is being given an inline height of 311px; 问题是你的<iframe>的内联height311px;

My guess would be that it's getting the height of the largest tab and applying it them all with this js: 我的猜测是它获得了最大的选项卡的高度并将它们全部应用于这些js:

function resizeIframe(obj) {
    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
  }

and or 和或

onload='javascript:resizeIframe(this);'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM