开发者

2 Minute question - HTML / CSS If div within div expands expand parent div

开发者 https://www.devze.com 2023-01-03 23:16 出处:网络
I have a setup lets say like follows: <div id=\"nav\"> <div id=\"innernav\"> //With dynamic content here.

I have a setup lets say like follows:

<div id="nav">
   <div id="innernav">
      //With dynamic content here.
   </div>
</div>

I am running a script that sizes #nav to the size of the browser window in height. But sometimes my dynamic content is now getting bigger than the height of the window.. Is there a way I can enforce that when #innernav exceeds #nav that #nav will increase in size?

Seen as someone asked for the script:

    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};

Changed the script to refer to min-height works perfectly in FireFox. But not IE or 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;
}


开发者_JS百科.nav {
width: 19%;
margin: 0px 0px 0px 0px;
background-color: #E0EFFF;
float: left;
vertical-align: bottom;
position: relative;       
}

some minor changes to my script / using min height seems to work. And after running a CCLEAN IE sort of does what I wanted.


Instead of setting the "height", set the "min-height".


short solution is give height auto to both divs

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号