Jan Erik Moström wrote:
> <http://www.latik.se/tmp/>
> My problem is the "blue" area, the left column. When I increase the
> padding of the horizontal navbar the content area is pushed down but
> not the left column and I don't understand why. Can anyone tell me
> why this happen?
Because W3C standards says so - seriously.
If you increase the padding bottom sufficiently - say: 100px, then both
#leftcolumn and #pagecontent are pushed down exactly the same amount.
However, depending on which browser you're using, it may not look like
the same amount. Some "nasty" 'collapsing margins'[1] and different
margin-defaults across browser-land, messes it up a bit.
What happens:
- #leftcolumn is a float, and floats contain 'collapsing margins'[1].
Thus, it moves down an exact amount of pixels equal to the
padding-bottom on #pagebar.
- #pagecontent in *not* a float or self-contained box[2], so the top
paragraph-margin is escaping it and pushes against the padding you've
added on #pagebar.
Vertical paddings have this effect on 'collapsing margins'[1] - making
#pagecontent move down an exact amount of pixels equal to the
padding-bottom on #pagebar + the amount of margin-top it has on the
first paragraph inside #pagecontent.
This paragraph-margin creates a gap _above_ the #pagecontent instead of
above the first paragraph inside #pagecontent - that's why it's called
'collapsing margin'[1].
This gap have different size in IE, Firefox, Opera etc, because they
have different margin-defaults on paragraphs. If you declare equal
margins on paragraphs (and other elements), then they will line up
identically.
In short: what a standard-compliant mess :-)
Solution: prevent those margins from escaping their containers -
collapsing - on all containers.
1: start by adding...
#pagecontent {padding: 1px 0;}
...to prevent paragraph-margins from escaping #pagecontent in all
browsers. This is just one way to achieve this effect, and the others
are described in the W3C sections linked to at the bottom of this mail.
2: add whatever padding-bottom size you want to #pagebar, and both
#leftcolumn and #pagecontent will move down perfectly in line with each
other.
-------
There are a few more potential traps when it comes to 'collapsing
margins', as IE does not understand and react the same as other browsers
on all standard properties we can use to "fix" the problems, and IE also
has a few variants of its own that are not written in any standard but
Microsoft's. See: 'hasLayout'[3].
Who said "learning CSS isn't fun" ;-)
regards
Georg
[1]http://www.w3.org/TR/CSS21/box.html#collapsing-margins
[2]http://www.w3.org/TR/CSS21/visuren.html#q15
[3]http://www.satzansatz.de/cssd/onhavinglayout.html
--
http://www.gunlaug.no
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
IE7 information -- http://css-discuss.incutio.com/?page=IE7
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/