Many suggest avoiding the use of table layouts and opting for divs and CSS instead, which I am happy to embrace. Please forgive me for asking a basic question.
I am looking to create a layout where the center content stretches out to cover the entire visible page, allowing it to scroll if it exceeds the visible area. The top, left, right, and bottom divs should remain fixed in their positions on the visible page. Despite my attempts, I have been unable to achieve this desired effect.
Does anyone have any suggestions on how to approach this problem?
|--------------------------------| <--- Visible page
| Top |
|--------------------------------| Right/left fixed with stretched height
|------| Center/content |------| Top/bottom fixed height stretched width
|------| |------|
|------| ^ |------|
|------| | |------|
| Left | <--stretch--> | Right|
|------| | |------|
|------| v |------|
|------| |------|
|--------------------------------|
| Bottom |
|--------------------------------|
Below is the base code without positioning for the div elements. I have tried various position properties like absolute, relative, etc., but encountered odd overflow issues with the top and bottom divs.
<body>
<style>
.container {
border: 3px solid #FF00FF;
width: 100%;
height: 100%;
}
.top {
background: red;
height: 3em;
width: 100%;
}
.bottom {
background: blue;
height: 3em;
bottom: 0;
}
.left {
background: green;
width: 5em;
}
.right {
background: gold;
width: 5em;
}
.content {
background: lightgreen;
height: 100%;
width: 100%;
}
</style>
<div class="container">
<div class="top">
Top
</div>
<div class="left">
Left
</div>
<div class="content">
Content
</div>
<div class="right">
Right
</div>
<div class="bottom">
Bottom
</div>
</div>
</body>