Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 10:33 PM
Brian
Guest
 
Posts: n/a
Default unwanted margin betwen divs

I have a page with content, navigation, and footer divs, in that
order. The nav div has position: absolute, width 8em, on green
background. The other divs have an 8em green left border, such that
the nav sits on that border. There is a thin red top border on footer
for testing.

http://www.tsmchughs.com/test/

On that page, all is as expected. However, on the long page
http://www.tsmchughs.com/test/long
there is an unwanted space of what looks like 1em between the content
and footer divs. Reproducible on Mozilla 1.3, O7.23, and MSIE
5.01/Windows2k.

Stranger still, by adding a bottom border on content
http://www.tsmchughs.com/test/longwb
I can make the space (almost?) disappear on Moz/Opera, though it's
still there in MSIE.

CSS:
http://www.tsmchughs.com/test/test.css

Any idea what is going on?

--
Brian (follow directions in my address to email me)
http://www.tsmchughs.com/

  #2  
Old July 20th, 2005, 10:33 PM
Lauri Raittila
Guest
 
Posts: n/a
Default Re: unwanted margin betwen divs

In article Brian wrote:
[color=blue]
> http://www.tsmchughs.com/test/
>
> On that page, all is as expected. However, on the long page
> http://www.tsmchughs.com/test/long
> there is an unwanted space of what looks like 1em between the content
> and footer divs. Reproducible on Mozilla 1.3, O7.23, and MSIE
> 5.01/Windows2k.[/color]

I see this space in both examples. It sounded like margin collapsing, and
it was margin collapsing.
[color=blue]
> Stranger still, by adding a bottom border on content
> http://www.tsmchughs.com/test/longwb
> I can make the space (almost?) disappear on Moz/Opera, though it's
> still there in MSIE.[/color]

That means it certainly is about margin collapsing. Bottom margin of last
paragraph is collapsed with bottom margin of content div.

Solutions:
- add some padding-bottom or border-bottom to content div.
- remove margin from last paragraph
[color=blue]
> CSS:
> http://www.tsmchughs.com/test/test.css[/color]

Thanks for clear testcase. Usually I need to hunt your CSS for ages ;-)

How to find what causes unwanted whitespace:
1. check if margins are collapsing
2. check whitespce in wrong places.


--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

  #3  
Old July 20th, 2005, 10:33 PM
Brian
Guest
 
Posts: n/a
Default Re: unwanted margin betwen divs

Lauri Raittila wrote:[color=blue]
> In article Brian wrote:
>[color=green]
>> on the long page http://www.tsmchughs.com/test/long there is an
>> unwanted space of what looks like 1em between the content and
>> footer divs. Reproducible on Mozilla 1.3, O7.23, and MSIE
>> 5.01/Windows2k.[/color]
>
> I see this space in both examples. It sounded like margin
> collapsing, and it was margin collapsing.[/color]

I didn't -- still don't, really -- know much about margin collapsing.
When I have time, I'll have to read up on it. I suppose it means that
a bottom margin on e.g. the last paragraph will become the
bottom-margin of a div with bottom-margin: 0. Not what I expected.
[color=blue]
> Solutions:
> - add some padding-bottom or border-bottom to content div.[/color]

Works in Moz/Opera. Does not work in MSIE 5.01/Win.
[color=blue]
> - remove margin from last paragraph[/color]

I hate to have to add all that style info to my css. I'll need it for
lots of pages. I guess I'll have to decide how imporant this is.
[color=blue]
> Thanks for clear testcase. Usually I need to hunt your CSS for ages
> ;-)[/color]

:-) Sorry for being lazy in the past. It's true that a test case is
better. It takes significant work, but it's for me to do rather than
ciwas participants.
[color=blue]
> How to find what causes unwanted whitespace: 1. check if margins
> are collapsing 2. check whitespce in wrong places.[/color]

Thanks a bunch. I would not have figured this out without some help.

--
Brian (follow directions in my address to email me)
http://www.tsmchughs.com/

  #4  
Old July 20th, 2005, 10:33 PM
Lauri Raittila
Guest
 
Posts: n/a
Default Re: unwanted margin betwen divs

In article Brian wrote:[color=blue]
> Lauri Raittila wrote:[color=green]
> > In article Brian wrote:
> >[color=darkred]
> >> on the long page http://www.tsmchughs.com/test/long there is an
> >> unwanted space of what looks like 1em between the content and
> >> footer divs. Reproducible on Mozilla 1.3, O7.23, and MSIE
> >> 5.01/Windows2k.[/color]
> >
> > I see this space in both examples. It sounded like margin
> > collapsing, and it was margin collapsing.[/color]
>
> I didn't -- still don't, really -- know much about margin collapsing.
> When I have time, I'll have to read up on it. I suppose it means that
> a bottom margin on e.g. the last paragraph will become the
> bottom-margin of a div with bottom-margin: 0. Not what I expected.
>[color=green]
> > Solutions:
> > - add some padding-bottom or border-bottom to content div.[/color]
>
> Works in Moz/Opera. Does not work in MSIE 5.01/Win.[/color]

I have no IE5.01, so I can't help. I past, I have used padding in P
instead of margin when making solid border around page. (I didn't wan't
to use wrapper div, as whole point of that example was not to need
wrapper div...)

The problem with using padding is that you luse advantages of margin
collapsing...
[color=blue][color=green]
> > remove margin form last P[/color][/color]
[color=blue]
> I hate to have to add all that style info to my css. I'll need it for
> lots of pages. I guess I'll have to decide how imporant this is.[/color]

Too bad CSS3 is not supported...
[color=blue][color=green]
> > How to find what causes unwanted whitespace:
> > 1. check if margins are collapsing
> > 2. check whitespce in wrong places.[/color]
>
> Thanks a bunch. I would not have figured this out without some help.[/color]

Tests:
1. * {margin:0;} or * {border:thin solid} -> whitespace goes away
-> it's margin collapsing
2. s/(\n|(>) | (<))/$2/g -> white space goes away -> it's white space bug
or something similar.
(I hope I did that correctly, I can't contact my unix shell to test at
moment)

Of course, neither is solution, but way to find out which one is the
problem, if either.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles