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