Zoals de titel zegt heb ik problemen met 100% height in te stelen van DIV-jes voor 2 kolomen onder een header in CSS.
Even wat beter uitleggen. Ik heb 3 DIV-jes in een DIV zitten. De bedoeling is dat ik een header en links en recht onder de header nog 2 DIV-jes heb, dus de kolomen zeg maar.
De laatste 2 moeten de rest van het scherm qua hoogte vullen. Bij te veel tekst van één van de twee moeten beiden groeien. Iets wat je vrij gemakelijk op gelost kan worden met tables maar ik wil een tableless site maken.
Hieronder de code die ik tot nu toe heb. Ik heb deze gemaakt door diverse pagina’s op internet door te lezen maar kom tch nergens een situatie met twee kolomen tegen. Misschien kunnen jullie mij helpen???
Even wat beter uitleggen. Ik heb 3 DIV-jes in een DIV zitten. De bedoeling is dat ik een header en links en recht onder de header nog 2 DIV-jes heb, dus de kolomen zeg maar.
De laatste 2 moeten de rest van het scherm qua hoogte vullen. Bij te veel tekst van één van de twee moeten beiden groeien. Iets wat je vrij gemakelijk op gelost kan worden met tables maar ik wil een tableless site maken.
Hieronder de code die ik tot nu toe heb. Ik heb deze gemaakt door diverse pagina’s op internet door te lezen maar kom tch nergens een situatie met twee kolomen tegen. Misschien kunnen jullie mij helpen???
HTML:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>CSS Layout - 100% height</title> <link rel="stylesheet" type="text/css" href="layout1.css" /> </head> <body> <div id="container"> <div id="header"> <h1>CSS layout: 100% height with header and footer</h1> <p>Sometimes things that used to be really simple with tables can still appear pretty hard with CSS. This layout for instance would consist of 3 cells; two with a fixed height, and a third one in the center filling up the remaining space. Using CSS, however, you have to take a different approach.</p> </div> <div id="side"> ??? </div> <div id="content"> <h2>Min-height</h2> <p> The #container element of this page has a min-height of 100%. That way, if the content requires more height than the viewport provides, the height of #content forces #container to become longer as well. Possible columns in #content can then be visualised with a background image on #container; divs are not table cells, and you don't need (or want) the fysical elements to create such a visual effect. If you're not yet convinced; think wobbly lines and gradients instead of straight lines and simple color schemes. </p> <h2>Relative positioning</h2> <p> Because #container has a relative position, #footer will always remain at its bottom; since the min-height mentioned above does not prevent #container from scaling, this will work even if (or rather especially when) #content forces #container to become longer. </p> <p> Scale the text size a bit or resize your browser window to test this layout. The <a href="css/layout1.css">CSS file is over here</a>. </p> </div> </div> </body> |
Cascading Stylesheet:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
| html,body { margin:0; padding:0; height:100%; /* needed for container min-height */ background:gray; color: #666; } div#container { position:relative; /* needed for footer positioning*/ margin: 0 auto; /* center, not in IE5 */ width: 750px; background: #f0f0f0; height:auto !important; /* real browsers */ height:100%; /* IE6: treaded as min-height*/ min-height:100%; /* real browsers */ } div#header { padding:1em; background: #ddd; border-bottom: 6px double gray; } div#side { float: left; width: 200px; background-color: #0000FF; position:relative; /* needed for footer positioning*/ height:auto !important; /* real browsers */ height:100%; /* IE6: treaded as min-height*/ min-height:100%; /* real browsers */ } div#content { float: right; width: 500px; background-color: #00FF00; position:relative; /* needed for footer positioning*/ height:auto !important; /* real browsers */ height:100%; /* IE6: treaded as min-height*/ min-height:100%; /* real browsers */ } |
