Solved

CSS layout for header, footer, 2-column body w/ nested content

Posted on 2006-06-18
5
888 Views
Last Modified: 2007-12-19
I am having issues in producing a layout using CSS only.  I would be grateful if one of the many CSS gurus in the community would help point me in the direction for creating a stylesheet that accomplishes my goal and remain cross-browser compatible.  Convention would suggest I post the code developed to this point.  But to be honest, I have found I do not have a clue as to what I am doing.  Further, in the process of synthesizing others code that achieves some of what I need to accomplish, my lack of skill has created a product that is a discordant and disparate mess of otherwise good code.  As such, please accept my humble apologies for not posting what I have created thus far.
 
The Goal:  Create a fixed header and footer that span the entire width of the top and bottom of the viewport, respectively.  In the remaining area would be two surrounds:  one for navigation and one for content.  The nav container would be 175px wide and 100% the remaining height; while the content container would occupy the remaining area.  Within the nav container would be a nested div that has a margin of 3px, a 1px black border and occupy 100% width and height of the nav container; any overflow would be hidden.  Within the content container would be a nested div that has a margin of 3px, a 1px black border, and occupy 100% width and at minimum 100% height of the content container.  Any overflow would spawn a vertical scrollbar over the content container.  

In the event my description was not clear, a GIF of the layout is available at http://www.propagranda.com/images/website_layout.gif.  Thank you in advance for the help.
0
Comment
Question by:pigouvian
  • 3
  • 2
5 Comments
 
LVL 30

Expert Comment

by:GrandSchtroumpf
Comment Utility
0
 

Author Comment

by:pigouvian
Comment Utility
Thanks GrandSchtroumpf for your reply.  I have gotten to this point, but am unable to get the DIVs that are nested in the nav and content surrounds that will contain the content to expand 100% width and height (less 3px margin).  Any thoughts?
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
Comment Utility
> but am unable to get the DIVs that are nested in the nav and content surrounds that will contain the content to expand 100% width and height (less 3px margin).
That's perfectly normal that you are unable to do it.
You can try something with min-height, but i have no idea how you'll be able to have mixed units (percentage minus pixels)...  And good luck if you need that to work in IE.
Another solution is to use javascript to resize your elements (or use an expression in IE).
But the best solution is to you adapt your layout to something that does not go against the fundamental principles of the CSS layout.
0
 

Author Comment

by:pigouvian
Comment Utility
Just to make sure I understand correctly, it is not possible to nest one DIV in another DIV, set the margin of the inner DIV to 3px, and have it fill the area of the outer DIV?  You are right that I probably don't understand the principles of CSS -- so I have a related question.  Are the parameters I set for the inner DIV relative to the dimensions of the outer DIV?
0
 
LVL 30

Accepted Solution

by:
GrandSchtroumpf earned 500 total points
Comment Utility
Exactly, it's not possible to have a block-level element "fill" the vertical available space.  All you can do is specify the height to be a percentage of the height of its direct parent...  But that won't give you a 3px margin.  Also, percentage heights only work when the parent's height is specified explicitely, otherwise it's interpreted as "auto".

When your CSS gets too complicated, it's usually because you don't do things the way they were intended to be done.
The idea about CSS layout is that it's the content that creates the structure.  That's completely the opposite of designing a "template" using tables, and then filling your template with content.

If you are starting with CSS, i suggest you start with a simple layout that respects the philosophy of CSS layout (my CSS-frameset is not a good example).  It's better not to specify any explicit heights.  And remember that if you do specify explicit heights, then you should also specify "overflow: auto".  Using "min-height" is fine, but not supported by IE6.

Start by coding your html with semantics in mind.  When your html is completely coded, then you can experiment with CSS and see what you can make out of it.  It's much better to do it this way.  Make the best use of what CSS has to offer and don't focus on what it cannot do.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now