Css Layout That Fills Available Space
Solution 1:
how about THIS? it works with konqueror (KHTML), chrome (webkit) and firefox (gecko). like anything recent, it will probably barf under IE6.
<html><bodystyle="margin: 0; padding: 0;"><divstyle="position: absolute; background: #faa;
height: 100px; top: 0px; width: 100%;">header</div><divstyle="position: absolute; background: #afa;
top: 100px; bottom: 100px; left: 0; width: 100px;">left</div><divstyle="position: absolute; background: #afa;
top: 100px; bottom: 100px; right: 0; width: 100px;">right</div><divstyle="position: absolute; background: #faa;
height: 100px; bottom: 0px; width: 100%;">footer</div><divstyle="position: absolute; background: #aaf;
bottom:100px; left: 100px;top: 100px;right: 100px; overflow: auto;"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam tincidunt tempor
velit quis volutpat. Nulla pharetra pulvinar arcu sed lacinia. Nulla ultrices aliquet sem,
vitae commodo elit condimentum ut. Nulla consectetur facilisis nibh, et tempus purus
pellentesque nec. Ut eu nibh ut arcu mattis luctus. Cras at interdum quam. Pellentesque
imperdiet mi vitae felis sollicitudin iaculis. Maecenas accumsan tortor neque, at posuere
felis. Quisque ultricies mi quis dolor pellentesque elementum. Maecenas quis nunc tortor.
Cras eu velit faucibus nulla volutpat mollis. Aliquam fermentum lobortis diam ut pharetra.
Duis mattis posuere fringilla. Morbi consectetur mauris vel libero pellentesque varius.
Aenean leo enim, placerat a feugiat nec, ultrices et nulla. Etiam tincidunt urna id justo
molestie faucibus. Cras neque enim, semper et sodales eu, volutpat nec urna. Vestibulum
interdum arcu et ante egestas ut lacinia dui semper. Cras ligula lacus, aliquet nec dapibus
ac, commodo vitae libero. In gravida venenatis sapien a convallis.</p><p>Nulla ac risus eu velit pulvinar pretium. Etiam porttitor viverra sollicitudin.
Donec lectus mi, posuere quis luctus facilisis, lacinia non ante. Sed sed mi neque. Etiam
neque risus, bibendum et tincidunt vel, pharetra nec risus. In hac habitasse platea
dictumst. Nam sollicitudin condimentum lorem, quis dignissim turpis sagittis nec.
Pellentesque diam nunc, rhoncus quis lobortis id, lacinia quis lorem. Maecenas tempor metus
nec velit facilisis in rhoncus lectus varius. Integer mollis, odio ut pharetra varius, elit
nulla pellentesque neque, a egestas est justo dapibus neque. Vivamus a mauris massa, sit
amet commodo orci. Aliquam nec iaculis sapien. Suspendisse ornare, tortor eget mattis
tempus, nulla ligula fermentum elit, vitae euismod odio metus ac risus. Etiam iaculis
dignissim consectetur. Nunc molestie lorem ac neque pulvinar vitae eleifend justo
facilisis.</p><p>Duis a sem turpis, et cursus arcu. Suspendisse potenti. Sed eu risus orci, eget
bibendum justo. Praesent dapibus porttitor mauris, ac sollicitudin eros pretium quis.
Curabitur mi eros, aliquam et ultrices et, adipiscing ut mauris. Nunc pretium malesuada nisi
laoreet consectetur. Phasellus mi arcu, rutrum in blandit in, consectetur non risus.
Vestibulum enim lacus, aliquam eu ultrices a, tempor ut turpis. Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Curabitur rhoncus faucibus sapien, quis vulputate eros tempus
consequat. Vivamus id metus massa. Vivamus aliquet enim quis sem viverra eu molestie elit
cursus.</p><p>Mauris at lorem massa. Aliquam risus ligula, vestibulum et placerat condimentum,
pellentesque sit amet justo. Cras tempor sollicitudin ultrices. Aliquam sed elit sapien.
Praesent consectetur molestie vehicula. Pellentesque quis lectus et nunc accumsan feugiat.
Ut rhoncus aliquet libero sed rhoncus. Fusce egestas nunc eu elit vestibulum placerat. Class
aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
Phasellus vitae nisi ante, id fermentum justo.</p><p>Donec iaculis magna nec elit fringilla imperdiet. Proin mauris sem, pellentesque sed
ultrices ac, luctus ac elit. Donec blandit, orci ac volutpat luctus, turpis sem malesuada
tellus, eget porta magna nisi vitae quam. In vitae scelerisque urna. Proin ante odio,
ultrices lobortis scelerisque at, dictum non justo. Pellentesque tincidunt congue leo
malesuada ullamcorper. Quisque dapibus, massa dignissim gravida blandit, augue felis
vehicula urna, et ullamcorper turpis orci sit amet nibh. Ut vitae consequat nibh.
Pellentesque turpis justo, ultrices ac porta in, pretium quis quam. Donec purus nisi,
dignissim vitae hendrerit vel, hendrerit ac sapien. Fusce facilisis purus a libero elementum
ultrices. Nunc in libero congue ipsum tempor suscipit. Pellentesque pharetra pretium
volutpat. Nam sapien arcu, viverra vitae euismod sit amet, mollis nec arcu. Phasellus at
elit metus, sit amet tempus turpis. Phasellus mattis justo ut est varius facilisis ut et
leo. Phasellus congue cursus est eget luctus. In eleifend diam at enim ultricies a lacinia
mauris molestie. Nunc porttitor bibendum vulputate. Pellentesque quis risus vel mi
pellentesque imperdiet vitae ac nunc.</p></div></body></html>
Solution 2:
I think this is a bit of a strange thing to try to do. Nevertheless, I took a shot at it, and I may have only gotten as far as you got, but maybe I used a different method that could be useful. I'm very interested to see if Rob has a better way. My method works, with one problem: the content is scrollable, but you can't see the scroll bars. I can't seem to think of a way to fix this. Anyway, here's what I came up with: http://www.happyspork.com/layout_test.html
Solution 3:
If anyone's interested I developed a layout that uses css
to emulate dynamic table
behaviour [using div
s]. It works in Chrome, Firefox and IE>7.
DEMO, have a go at resizing the window
As it stands all five components grow as their respective contents do, however, if you really want your left and right sides fixed just apply a width
rule to .east
and .west
.
Have a fiddle with it.
Code:
<divclass="view"style="height:100%; width:100%"><divclass="north">
n
</div><divclass="middle"><divclass="west">
w
</div><divclass="centre">
c
</div><divclass="east">
e
</div></div><divclass="south">
s
</div></div>
html, body {
height : 100%;
margin : 0;
}
.view,
.view > .middle {
display : table;
}
.view > .north,
.view > .south {
height : 1px;
display : table-row;
}
.view > .north { vertical-align : top; }
.view > .south { vertical-align : bottom; }
.view > .middle > div {
display : table-cell;
}
.view > .west,
.view > .east {
width : 1px;
}
/*div { border : 1px solid black; }*/
Simple markup, no JS, and dynamic layout. Uncomment the border
css line to see whats going on.
At the bottom of your question I see you tried using tables but with issues. Placing a max-height
on centre
or middle
might be what you want (for the scrollbar thing). Maybe this can help you.
Post a Comment for "Css Layout That Fills Available Space"