javascript - 在 Chrome 中调整 div 大小的问题

标签 javascript css google-chrome resize height

编辑:当高度分辨率低于整个页面(例如: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";        
  }
}

最佳答案

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

将“overflow:auto”样式添加到“conteudo”div,这通常是安全的,或者

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

尽管如此,我没有在 Chrome 11 中看到您的错误,但我猜其中一个可能会修复它。

关于javascript - 在 Chrome 中调整 div 大小的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5997072/

相关文章:

javascript - 将div滑动到屏幕顶部

javascript - FooTable 的分页 : a jQuery Plugin for Responsive Data Tables

javascript - HTML/JS 代码可以在普通浏览器 View 中运行,但无法作为 Chrome 扩展运行?

具有基于表单的身份验证的 Java Applet 在 IE 上工作但在 Chrome 上失败

javascript - 您如何通过桌面版 Google Chrome(如 Instagram)访问 native 登录功能?

javascript - 流行的 Big Buck Bunny mp4 视频上的 "Cannot play media. No decoders for requested formats"

javascript - 使用名称属性在循环中检查第一个单选按钮

html - 与图像一起调整 hover_mask 的大小

javascript - 重新创建对象数组的方法返回重复相同对象的相同数组

jquery - 使用引导开关切换禁用输入框