Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Working in Chrome but not Firefox ( div height )

I have been building a website and mainly testing it in Chrome. Recently I realised some of the CSS does not apply in Firefox.

I guess it's probably : main { min-height }

This jFiddle reproduces this error, where the main div doesn't have the height it's supposed to. http://jsfiddle.net/msW9m/

HTML :

<div id='main'></div>
<div id="container"></div>
<div id='footer'>
    <div id='footerRelative'>Development by <a href='mailto:'>John Doe</a></div>
</div>​

CSS :

#main {
    min-height: 80%;
    height: auto;
    border: 1px solid #bbbbbb;
    margin: 3% 5% 1%;
    padding: 10px 10px;
}
#footer {
    position: absolute;
    left: 50%;
}
#footerRelative {
    position: relative;
    left: -50%;
    font-size: 80%;
}
/*Probably Irrelevant*/
#container {
    margin: 0 auto;
    margin-top: -300px;
    margin-left: -261px;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 523px;
    height: 600px;
    background-image: url('../images/doctorSymbol.jpg');
    background-repeat:no-repeat;
    background-position:center;
    opacity: 0.125;
    overflow: hidden;
    z-index: -1;
}

However, in Chrome everything works perfectly and the main div has a min-height of 80% . I was wondering if there is a workaround to this or If I am doing something wrong.

Thank you.

like image 660
hermann Avatar asked May 15 '12 18:05

hermann


2 Answers

Have you tried making body and html 100%?
In some browsers, the body element doesn't keep 100% height until its content is full.

http://jsfiddle.net/HRKRN/

html, body {
    height: 100%;
}
like image 69
Renan Azevedo Avatar answered Sep 21 '22 23:09

Renan Azevedo


Also a possible solution that worked for me: set the div's display to table-cell.

like image 43
Ian Avatar answered Sep 18 '22 23:09

Ian