Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solid solution for div/body height 100%

Tags:

html

css

I think we need to find a solid solution for this problem - on the internet, there does not seem to be one.

The DIV will always stay the height of its content - and not more.

The structure is like this:

<html>
    <head>
        <title>myPage</title>
    </head>
    <body>
        <div id='container'>
            Some Content...
        </div>
    </body>
</html>

CSS usually looks like this:

body {
    height: 100%;
}
div#container {
    height: 100%;
    width: 100%;
}

There are already tricks with setting margin or/and padding on body or/and div, but nothing seems to work really fine.

Is there a one and only solution for this problem?

like image 322
Florian Müller Avatar asked Mar 09 '26 01:03

Florian Müller


1 Answers

html, body, div#container{
   min-height: 100%;
   height: 100%;
}

May be this will help?

like image 151
DaneSoul Avatar answered Mar 10 '26 15:03

DaneSoul