3 equalizing col layout +header +footer

Hi,

Well if your element doesn’t have a set height then the element you want at the bottom should just follow the content without any positioning at all. You can of course keep them apart using margins etc.

If your element has a set height and you want to place something at the bottom then you will need to place it there absolutely. This removes it from the flow so you need to make sure the content above doesn’t overwrite it.

This can be accomplished in various ways but perhaps the easiest is too add some padding to the bottom of the parent element that is the same height as the absolutely placed element which will allow it to be prtected from being overwritten.

Heres a quick example.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd](http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)">
<html xmlns="[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
#outer {
 width:30%;
 padding-bottom:30px;
 position:relative;
 color:red;
 background-color: #D1DCE9;
}
#stayatbottom {
 position:absolute;
 bottom:0;
 left:0px;
 height:30px;
 line-height:30px;
 width:100%;
 color:#ffffcc;
 background:blue;
 text-align:center;
 overflow:hidden;
}
</style>
</head>
<body>
<div id="outer"> 
  <p>This is the content : This is the content : This is the content : This is 
	the content : This is the content : This is the content : </p>
  <div id="stayatbottom">I'm at the bottom of this div</div>
</div>
</body>
</html>

Hope that gives you some ideas :slight_smile:

Paul

I’ve been looking over the code for awhile now, messing around with things, and trying to duplicate it to help me understand, but I still can’t figure out what part of this page causes the columns to equalize.

http://www.pmob.co.uk/temp/2columncentred_equalising.htm

Hi alteredskate,

In that particular example the column effect is created by a repeating background gif here.


#content {
border: 1px solid #000;
padding: 0;
[b]background-image: url(images/navbg.gif);/*this is the background colour of the left column */
[/b]background-repeat: repeat-y;
background-position: left top;
}
 

and the right column colour is the background colour here:


#container {
width: 670px;
margin: 0px;
margin-left: auto;
margin-right: auto;
[b]background-color: #829CC8;/* this is the background colour of the right column */
[/b]border: 1px solid #000;
text-align:left;
}

The image is as wide as the column needs to be and is repeated down the left side of the container. Basically its as simple as that.

The container holds two floats which stretch the outer containers bottom border when any one of the floats is the longest. Because the background of the left column is a repeated gif you always get a full length column colour. The background of the right column is just the normal background colour of the container.

The actual floated columns themselves have no bg colours of their own otherwise they would mess the effect up.

This is the simplest way to achieve two equalising column colours and is completely hack free. If you look at my other two column demos there are examples that don’t even need bg images but are a little more complicated to use.

We can simplify it further here:

You have an outer (Content) that contains two floats. The left side of the Content could have a repeating bg gif that is as wide as the left float. The rest of the content (right column) is just the bg colour of the element.

You then just put your floats inside and you get the illusion of 2 columns. If you were to colour the floats then you would see that they don’t stretch full height but just expand to their content. However since we have already coloured the columns then the floats don’t need to be coloured.


#content {
background-color: #829CC8;/* this is the background colour of the right column */
border: 1px solid #000;
padding: 0;
background-image: url(images/navbg.gif);/*this is the background colour of the left column */
background-repeat: repeat-y;
background-position: left top;
}
#left {
float:left;
border-right:1px solid #000;
width:199px;
}
#right {
float:left;
width:465px;
border-left:1px solid #000;
margin-left:-1px;/* makes border line up with #left border */
}

Whole simplified page example :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd](http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)">
<html xmlns="[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
#content {
background-color: #829CC8;/* this is the background colour of the right column */
border: 1px solid #000;
padding: 0;
background-image: url(images/navbg.gif);/*this is the background colour of the left column */
background-repeat: repeat-y;
background-position: left top;
width: 670px;
margin-left: auto;
margin-right: auto;
}
#left {
float:left;
border-right:1px solid #000;
width:199px;
}
#right {
float:left;
width:465px;
border-left:1px solid #000;
margin-left:-1px;/* makes border line up with #left border */
}
</style>
</head>
<body>
<div id="content"> 
<div id="left"> 
	<p>This is the left content text.</p>
	<p>The background colourof this colums is a repeated image along thebackground 
	 y-axis of the container.</p>
	<p>The right border of this float is merged with the left border of the right 
	 content to appear as one continuous border.</p>
	<p>This is the left content text.</p>
	<p>This is the left content text.</p>
	<p>This is the left content text.</p>
	<p>This is the left content text.</p>
	<p>This is the left content text.</p>
</div>
<div id="right"> 
	<p>This is the right content text.</p>
	<p>Any column can be the longest and the columns will equalise.</p>
	<p>This is the right content text.</p>
	<p>This is the right content text.</p>
</div>
<div style="clear:both"></div>
</div>
</body>
</html>

(The three column examples use completely different techniques.)

Hope that makes it a bit clearer.

Paul

It does make things clearer. I couldn’t get it to work when making my own because I didn’t see the importance of a background image. Thanks.

Hello, i am using the 3 col example (nice work !) but have a minor issue with the centre column… (Viewed in IE6)

when the contenst of the centre column get longer than the left hand column - the centre column seems to get slightly wider

e.g. http://www.spikeopaths.org.uk/maps.php

i guess i’m nissing something obvious but any advice woould be gratefully received

also - any general feedback on the html/css structure would be good if anyone can spare a few minutes

Thanks

Steve

Hi,

I think you’re talking about the 3 pixel jog in ie and this can be fixed by also adding this css at the end of the stylesheet.


* html .contents {height:1%}

You already have it on #middle but sometimes its also needed on inner containers as well.

Regarding your page you have designed it basically for ie because you have used a partial doctype without uri. This puts ie6 into quirks mode and uses the broken box model (as ie5 and 5.5. do all the time in any mode).

Therefore all padding and borders will be contained within an elements width but in compliant browsers padding and borders are added to the width. This means your display will be incorrect in those browsers unless you take care of it.

You should always run your css and html through the w3c’s validators to pick out any errors such as typos and bad coding. Unfortunately you have 325 errors in your page but most are simple missing quotes etc but some are incorrect nesting that may affect more compliant browsers.

Its always worth having valid code as there is more chance of it working correctly and is easier to debug.

In your css you have missed the units (px) off a couple of items and mozilla will treat the measurement as zero and ie will guess that you meant pixels.

Once you’ve tidied that up you will have a much more reliable page and it will be easier to manage. Try not to mix the case of the elements as it looks messy and is hard to debug. I always keep evertyhing in lower case because I use xhtml and I now dislike any html that is in upper case and I think it looks messy (IMHO).

The look of your page is fine though :slight_smile:

Hope the solution above helps with your page and good luck with tidying the html up :wink:

Paul

Thanks paul

yep it was the 3px jog…sorted !

now wading through the zillions of errors !

thanks for the tips

Steve

Hello again - well have corrected the errors as indicated by the validator but the page now looks a bit dodgy ! slightly in IE6 but pretty random in Opera 7.5

Any pointers gratefully received !

As an aside - it seems to require a lot of effort to make the 3 column effect look the same in all browsers. Would it not be easier to have 3 column table as the container for my page instead of all the divs etc??? (this is where the blue touch paper bit comes in as i’m sure this is very non-CSS !)

e.g. something like …

<div>HEADER GOES HERE<//div>
<table>
<tr><td>COLUMN 1</td>
<td>COLUMN 2</td>
<td>COLUMN 3</td>
</tr>
</table>
<div>FOOTER GOES HERE</div>

just a thought !

also - is there a free resource (web site) which would indicate what the page looks like in each browser (saves me installing each one and checking the page)

thanks

steve

Hi,

You are free to use tables but you’ll get no help from me as I can never get them to work and I only use them for tabular data. I have more problems with tables than any css design I’ve ever done :slight_smile:

Try these links for checking out browsers although you’ll have to pay for some.

http://www.browsercam.com/
http://www.danvine.com/icapture/
http://www.danvine.com/iecapture/
http://www.anybrowser.com/

The easiest option is to download as many browsers as you can.

http://www.skyzyx.com/archives/000094.php

http://browsers.evolt.org/

Paul

Hey, I’ve been messing around with this 3-column design to eliminate tables and frames entirely from my site, and so far it works great! You can’t tell the difference between my old design and my overhaul.

One small problem…

I need a way to have a nav menu with nested submenus in the left column and do it in a way that I don’t need to change EVERY page on my site every time I need to change the menu. Also, when a user clicks on a menu item, the content should appear in the center column.

I am using dynamicdrive.com’s “switch menu” for the navigation.

Cany anyone help?

-Mike

Hi,

Well you could either look at SSI (server side includes) to include your menu on every page and then you only need one copy.

As for the content appearing in the centre then you are limited to a)Frames (very bad) , b iframes (better), or c) just a normal page.

If its only a small bit of content you could hide and show elements etc but that soon gets messy.

Either way its not really a css question that I can help more with :wink:

Paul

OK so i persevered and its finally getting there - with no tables and i think i have fixed the validation errors !

Couple of questions if you have time … example is at http://www.spikeopaths.org.uk/

  1. Looks fine in IE6 but in Opera 7.5 the menu and calendar boxes seem to be moved towards the centre (in IE6 they are aligned with the header)

  2. In the calendar section - the calday SPAN doesn’t seem to be using the defined width so the right-hand columns aren’t lined up !

  3. The search form DIV seems too big ? is there a way of specifying size etc (to be honest - not looked at this yet but any advice would be most welcome) - HAVE SORTED THIS - JUST ADDED margin:0px to the FORM

  4. Could you suggest another popular browser to have a quick check with ? (navigator maybe)

Thanks for your help so far

Steve

Paul,

Thanks for pointing me in the right direction. Upon searching the forums, I discovered that quite a few people are looking for this solution. So, for anyone else looking for an answer, here’s the info that helped me:

And for anyone who uses PHP:

Yes, SSI (Server Side Includes) is what you want. So if the site is PHP it is simply

<? include (‘menu-file.php’);?>

where menu-file.php is a single file that can be included anywhere on any php page.

And if the pages are .html it is

<!–#include virtual=“menu-file.html” –>

same deal, but call the parent pages with the extension .shtml

and so on for other languages.

That last bit was posted by gdape on May 11, 2004 here:

Worked like a charm for me! :smiley:

Thanks for letting us know you got it sorted :slight_smile:

SSI 's are very useful.

If you have DW you can use their template system which allows the update of all your pages through just changing the main template. However you still have to upload all the pages after you’ve changed them.

Withh SSI you just upload the one file and away you go :slight_smile:

Paul

Hi Steve,

) Looks fine in IE6 but in Opera 7.5 the menu and calendar boxes seem to be moved towards the centre (in IE6 they are aligned with the header)

I’ll work through these as I get to them.

Take the padding out of middle and put it in to contents


#middle		{border-width: 0px;}
.contents{padding:15px;}

Paul

  1. In the calendar section - the calday SPAN doesn’t seem to be using the defined width so the right-hand columns aren’t lined up !

Lined up with what? I’m not sure what I’m looking for.

Anyway you can’t define width for a span because its an inline element and won’t accept widths. You need to use a block level tag such as <p>. etc or more semantically perhaps a list (ul, li etc).(you could turn the span into display:block and then itr would accept widths and give a linefeed but other tags will do that anyway )

You shouldn’t need breaks at all to make line feeds if you code correctly.

Paul

  1. Could you suggest another popular browser to have a quick check with ? (navigator maybe)

These are what I use when testing:

ie5
ie5.5.
ie6
mozilla 1.2+
firefox
Opera7

When I’m happy with those then I will work on minor browsers such as.

Netscape 6.2
(Maybe also ie5 mac. - but nothing works properly in that)
Opera 6 (but not too bothered)

Paul

excellent - sorted - thanks !

is there any simpler tutorials? This one is soo large and complicated. I read half way through and I was completely lost… can someone help me?

anyone come on AIM; Emperor Amirsan

Hi Amirsan,

Iv’e replied in your other thread so hopefully that will help you :slight_smile:

paul