Professional Documents
Culture Documents
- Stack Overflow
1 of 5
http://stackoverflow.com/questions/10594197/divide-content-area-into...
sign up
log in
tour
help
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no
registration required.
I'm looking at making the transition from HTML tables to pure CSS layouts. So far, the one thing that eludes me is how to layout a
page properly.
I can do:
header
left navigation
content
footer
So like this:
________________________
|
Header
|
|_______________________|
| Left |
Content
|
| Nav |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|______|________________|
|
Footer
|
|_______________________|
However, on some pages I want to be able to divide the "content" area into something like the following:
________________________
|
Header
|
|_______________________|
| Left | info | info
|
| Nav |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|______|_________|
|
| Other info
|
|
|
|
|
|
|
|
|
|
|
|
|
|______|________________|
|
Footer
|
|_______________________|
Anyone know how something like this would be done? Or even a nice website that helps with this kind of thing?
css
layout
html
19
67
106
225
19
5 Answers
4/28/2015 12:48 AM
2 of 5
http://stackoverflow.com/questions/10594197/divide-content-area-into...
4/28/2015 12:48 AM
3 of 5
http://stackoverflow.com/questions/10594197/divide-content-area-into...
html:
<div id="header">Header</div>
<div id="main-wrap">
<div id="sidebar">Left Nav</div>
<div id="content-wrap">Content</div>
</div>
<div id="footer">Footer</div>
css:
/* sizes */
#main-wrap > div { min-height: 450px; }
#header,
#footer {
min-height: 40px;
}
/* layout */
#main-wrap {
/* overflow to handle inner floating block */
overflow: hidden;
}
#sidebar {
float: left;
width: 30%;
}
#content-wrap {
float: right;
width: 70%;
}
4/28/2015 12:48 AM
4 of 5
http://stackoverflow.com/questions/10594197/divide-content-area-into...
#content-wrap
<div id="header">Header</div>
<div id="main-wrap">
<div id="sidebar">Left Nav</div>
<div id="content-wrap">
<div id="info-wrap">
<div class="info">small info </div>
<div class="info">small info</div>
</div>
Content
</div>
</div>
<div id="footer">Footer</div>
css
/* sizes */
#main-wrap > div { min-height: 450px; }
#header,
#footer {
min-height: 40px;
}
.info { min-height: 80px; }
/* layout */
#main-wrap {
/* overflow to handle inner floating block */
overflow: hidden;
}
#sidebar {
float: left;
width: 30%;
}
#content-wrap {
float: right;
width: 70%;
}
#info-wrap {
/* overflow to handle inner floating block */
overflow: hidden;
}
.info {
width: 50%;
float: left;
}
25
71
So is the key here to force the sidebar to be an absolute position? That way you can use left float in other
areas and it won't conflict? Fittersman May 15 '12 at 14:17
4/28/2015 12:48 AM
5 of 5
http://stackoverflow.com/questions/10594197/divide-content-area-into...
@Fittersman i remembered better and simpler (without absolute position) way to handle this markup and
updated the answer. In all areas we can use float without conflict Vladimir Starkov May 15 '12 at 14:58
Give one of the CSS grid systems a go. This site lists some:10 Really Outstanding and Useful
CSS Grid Systems
answered May 15 '12 at 4:41
Paul Marrington
161
http://grids.heroku.com/fluid_grid?column_amount=3
You can add and delete these grids.
edited May 15 '12 at 4:48
14
24
For your content div set that a width then create three divs for the info sections.
The top two give a width and make sure they dont exceed the total of the container content.
float one left and the other right.
underneath the divs add:
<div class="clear"></div>
Under the clear will be your third div which will give you that layout you want.
answered May 15 '12 at 8:09
V0X
344
10
4/28/2015 12:48 AM