我有一个设置,如下所示:
<div id="nav">
<div id="innernav">
//With dynamic content here.
</div>
</div>
我正在运行一个脚本,该脚本将 #nav 的大小调整为浏览器窗口的高度大小。但有时我的动态内容现在变得比窗口的高度还大。当 #innernav 超过 #nav # 时,有什么方法可以强制执行吗? nav 会变大吗?
被视为有人要求脚本:
function resizeWindow(){var a=getWindowHeight();document.getElementById("content").style.height=(a-0)+"px";document.getElementById("nav").style.height=(a-0)+"px";document.getElementById("contentPanel").style.height=(a-10)+"px"}function getWindowHeight(){var a=0;if(typeof(window.innerHeight)=="number"){a=window.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){a=document.documentElement.clientHeight}else{if(document.body&&document.body.clientHeight){a=document.body.clientHeight}}}return a};
更改脚本以引用 min-height 在 FireFox 中完美工作。但不是 IE 或 Chrome。
CSS:
body {
margin: 0px;
text-align: left;
font-family: Verdana;
font-size: 11px;
background-color: #FFFFFF;
min-width: 980px;
min-height: 10px;
background-image: url('../Images/watermark.png');
background-position: 100% 100%;
background-repeat: no-repeat;
}
.nav {
width: 19%;
margin: 0px 0px 0px 0px;
background-color: #E0EFFF;
float: left;
vertical-align: bottom;
position: relative;
}
对我的脚本进行一些小改动/使用最小高度似乎有效。在运行 CCLEAN IE 之后,它会做我想做的事。
最佳答案
设置“最小高度”而不是“高度”。
关于javascript - 2 分钟问题 - HTML/CSS If div within div expands expand parent div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3059321/