I am having problems working on a project for school, what we are doing is creating div sections. And within each div section I color coded them to see them more clear. Though in my leftnav div it will not branch down to the bottom to the footer. JSFIDDLE here- http://jsfiddle.net/rM8zw/
if someone could help me fix this and explain what i did wrong? I have three container divs, so that some of my inherits would work correctly. Container for leftnav and bodyline, container for main site, container for BmiddleLeft and Right. Thanks guy ahead of time.
I am trying to figure out why my #leftnav will not complete its height to my bodyline so it is even.
heres the CSS-
#container{
width:980px;
height:auto !important;
height:900px;
min-height:900px;
padding-top:20px;
padding-bottom:20px;
margin: 0 auto;
boder: solid 0px;
overflow:hidden;
}
#holder{
width:980px;
height:auto !important;
height: 800px;
min-height:800px;
padding:0;
margin:0 auto;
border: solid 0px;
overflow:hidden;
background:#FFF;
}
#header{
width:980px;
height:100px;
border:solid 0px;
margin:0 auto;
padding:0;
background:#FF0000;
}
#navbar{
width:980px;
height:40px;
border:solid 0px;
margin:0 auto;
padding:0;
background:#c0c0c0;
}
#bodycontainer{
width:980px;
height:800px;
min-height:800px;
height:auto !important;
overflow:hidden;
}
#leftnav{
float:left;
width:200px;
height:1200px;
min-height:1200px;
height:auto !important;
padding:0;
overflow:hidden;
}
#bodyline{
float:right;
width:780px;
height:800px;
min-height:800px;
height:auto !important;
background:#00FF40;
overflow:hidden;
}
heres the HTML I am currently using-
<div id="container">
<div id="holder">
<div id="header">
</div>
<div id="navbar">
</div>
<div id="bodycontainer">
<div id="leftnav">
</div>
<div id="bodyline">
<div id="Btop">
</div>
<div id="BmiddleCont">
<div id="BmiddleLeft">
hello
<br />
</div>
<div id="BmiddleRight">
</div>
</div>
<div id="Bbottom">
</div>
<div id="BbottomLast">
</div>
</div>
</div>
</div>
<div id="footer">
</div>
</div>
hope this is a little better.
If you set the
min-heightasinherit, then it will go up until it finds a value. In this case, up to#container, which has it set to900px. That’s why theheightof your#leftnavis only900px.min-heightoverridesheight. Furthermore, if you takemin-heightout and keepheight: auto, then you have no restrictions imposed on theheight, so theheightof yourleftnavbecomes theheightof its content. Which is0in this case.There are a few ways in which you could set its
height. The easiest one of all, since you are explicitly setting heights on all the elements on the right, would be to add them up and then explicitly set that resulted value as theheightof yourleftnav.If those values are just dummy values and the heights of the elements on the right will depend on the
heightof the content in them, then you have a couple of options:1. Actually setting the
heightof your#leftnavto theheightof its parent (#bodycontainer). You do that by setting itspositiontoabsolute(and don’t forget to setposition: relativeon the parent) and its top, left, bottom values to 0. In this case, you’ll also have to set thepadding-leftof its parent (#bodycontainer) to the same value as#leftnav‘swidth(200pxhere). Or setleft-margin: 200px;on its sibling (#bodyline) to avoid having to modify thewidthof#bodycontaineror to set itsbox-sizingtoborder-box. – DEMO2. Make it look like it has the same
height.a) The easy method. Use a
gradientwith color stops as thebackgroundof the parent (#bodycontainer) – DEMO // demo without redundant codeKeep two things in mind:
(see caniuse.com for more details)
b) The best compatibility method (works in IE8+). Use a pseudo-element on the parent,
#bodycontainer, position it absolutely, set itstop,leftandbottomvalues to0, give it#leftnav‘swidthand the desiredbackground. – DEMO // demo without redundant code