Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS min-height not working properly

Tags:

html

css

Here is the situation, I have this html:

<div id='main'>
    <div id='menu'>
        Menu Items Here
    </div>
    <div id='cont'>
        Content Here
        <div id='footer'>Some Footer</div>
    </div>
</div>

CSS here:

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

#main{
    overflow : auto;
    background-color: yellow;
    width : 100%;
    min-height : 100%;
}

#menu {
    background-color: red;
    float : left;
    width : 300px;
}

#cont {
    margin-left : 300px;
    float : right;
    background-color: orange;
    width : 100px;
    min-height : 100%;
    height: auto !important; /*min-height hack*/
    height: 100%;            /*min-height hack*/
}

What I want to do basically is #cont div must have a min height of 100% (if I have small content) but will extend if have longer content.

Any help would be appreciated.

Note: The width size is just temporary for now.

Thanks!

like image 976
Eddie Avatar asked May 10 '14 15:05

Eddie


People also ask

Why is height not working CSS?

Height % is based on it's parent (so you have to set every element above the target element to 100%) , there are a few workarounds to this though. For instance you can set it to height: 100vh; This will create the element to be 100% of your window height. Or you can use px instead.

Can I use height and Min height together?

The min-height property in CSS is used to set the minimum height of a specified element. The min-height property always overrides both height and max-height . Authors may use any of the length values as long as they are a positive value.


1 Answers

This may work:

#main{
    height : 100%;
}
#cont {
    min-height : 100%;
    /* Without the hacks */
}
like image 61
agrm Avatar answered Sep 22 '22 12:09

agrm