【问题标题】:Problem resizing div in Chrome在 Chrome 中调整 div 大小的问题
【发布时间】:2011-08-25 05:17:55
【问题描述】:

编辑:当高度分辨率低于整个页面(例如:1024x768)时,可以在此页面中看到发生了什么:http://www.depositosalto.com.br/pagamentos.php

我尝试使用 javascript 调整具有页面内容的 div 的大小,以使页面在较小时始终适合整个屏幕。

我正在使用以下 javascript,它适用于其他导航器(Firefox、Opera)。在 Chrome 中,它也会调整 div 的大小,但与其他的不同,它不会推送位于内容 div 下方的页脚 div。

chrome有什么办法解决吗?

function defineContentHeight(height){       
  var screenHeight = window.innerHeight;                
  if (screenHeight > (height + 220)){
    height = screenHeight - 220;                
    document.getElementById("content").style.height = height + "px";        
  }
  else{                     
    document.getElementById("content").style.height = height + "px";        
  }
}

【问题讨论】:

    标签: javascript css google-chrome resize height


    【解决方案1】:

    “conteudo” div 内的内容是浮动的,因此不计算高度;你可以做以下两件事之一:

    在“conteudo”div中添加“overflow:auto”样式,一般是安全的,或者

    在“conteudo”div 的最底部添加一个样式为“clear:both”的 div

    对于它的价值,我在 Chrome 11 中没有看到你的错误,但我猜其中一个可能会修复它。

    【讨论】:

    • 是的,没有更多的错误。我认为我描述的问题与其他问题有关。我遇到了编码问题(页面不能在 IE 中正确显示,而 Chrome 中的这个错误),但在修复编码后,IE 问题消失了,顺便说一句,Chrome 的问题也遵循了相同的路径。感谢您的关注。
    • 试试css resize: both
    猜你喜欢
    • 2011-04-04
    • 2012-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-17
    • 2017-09-09
    • 1970-01-01
    相关资源
    最近更新 更多