Question

Im using the css

html, body {
    padding: 0;
    margin: 0;
    height: 100%;
}

tag for my website to make some div's be 100% in height, but when I add it in it messes my html up like so: http://prntscr.com/2xmqq8, but when I take it out, it goes back to normal, but the left div height isn't 100% like so: http://prntscr.com/2xmrmf? Why does it do this and how do I fix it?

Html:

<div id="wrapper">
     <div id="header">
        some stuff here
     </div>
     <div style="clear:both">
     </div>
     <div id="content">
        <div id="left">
           some stuff here too
        </div>
     </div>
</div> 

Css :

html, body {
    padding: 0;
    margin: 0;
    height: 100%;
}

#content #left {
    width:295px;
    min-height:100%; 
    border-right: 1px dotted #000; 
    padding: 0 0 0 10px;
    float: left;
}

#wrapper {
    background:url(../images/wrap_bg.png);
    width: 1240px;
    height:100%;
    margin-left:auto;
    margin-right:auto;
}

#wrapper #content {
    width: auto;
    height:100%;
}
Was it helpful?

Solution

Try it. Note that I have included only necessary changes to your examples.

body {
    padding: 0;
    margin: 0;
}
#content #left {
    height: 100%;
    position: absolute;
    top: 0;
    z-index: -1; /* Hide right border below #header */ 
    box-sizing: border-box; 
    /*padding: 0 0 0 10px;*/
    padding-top: 30px; /* Height of #header */
}

If negative z-index not working in older browsers, then use following style.

#header {
    position: relative;
    z-index: 1;
    background: #fff;
}

OTHER TIPS

You dont need

html, body 

You can replace it with

body {...};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top