Solved

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

Posted on 2006-06-18
5
889 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
ID: 16932729
0
 

Author Comment

by:pigouvian
ID: 16935896
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
ID: 16937789
> 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
ID: 16938301
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
ID: 16940763
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"I want to put my photos online, but I don't want them stolen.  What settings should I use?" When You Put Photos Online First and foremost, any digital file published on the WWW can be copied, stored, modified, retransmitted, etc.  Remember Naps…
When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

863 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

23 Experts available now in Live!

Get 1:1 Help Now