473,385 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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/

Jul 20 '05 #1
3 3481
In article Brian wrote:
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.
I see this space in both examples. It sounded like margin collapsing, and
it was margin collapsing.
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.
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
CSS:
http://www.tsmchughs.com/test/test.css


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.

Jul 20 '05 #2
Lauri Raittila wrote:
In article Brian wrote:
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.
I see this space in both examples. It sounded like margin
collapsing, and it was margin collapsing.


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.
Solutions:
- add some padding-bottom or border-bottom to content div.
Works in Moz/Opera. Does not work in MSIE 5.01/Win.
- remove margin from last paragraph
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.
Thanks for clear testcase. Usually I need to hunt your CSS for ages
;-)
:-) 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.
How to find what causes unwanted whitespace: 1. check if margins
are collapsing 2. check whitespce in wrong places.


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/

Jul 20 '05 #3
In article Brian wrote:
Lauri Raittila wrote:
In article Brian wrote:
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.
I see this space in both examples. It sounded like margin
collapsing, and it was margin collapsing.


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.
Solutions:
- add some padding-bottom or border-bottom to content div.


Works in Moz/Opera. Does not work in MSIE 5.01/Win.


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...
remove margin form last P 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.


Too bad CSS3 is not supported...
How to find what causes unwanted whitespace:
1. check if margins are collapsing
2. check whitespce in wrong places.


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


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.

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Brynjar Glesnes | last post by:
Hi, I've browsed the Fop FAQ, usenet and the internet hoping to find a solution to my problem, but in vain. I am using Xerces 2.6.2, Xalan-J 2.6.0 and Fop 0.20-5 to create PDF-documents. In...
5
by: Mike Irwin | last post by:
Here's the test page: <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">...
6
by: Tony T | last post by:
Can anyone help me with this - it may be obvious, but I just can't see it. I'm working with PC and WinME. In IE6, the two divs inside the wrapping div have no space between them, which is how I...
0
by: bugbear | last post by:
I was struggling with some elaborate nested divs, and my styles were working fine on everything (even Mac/ie5.2) *except* IE6.0 on Windows 2000 professional. I have 2 nested DIVS, both...
26
by: meltedown | last post by:
I have 2 left floating divs on a page. Sometime the left side is larger, sometimes the right side is larger. I want the page to have a margin at the bottom of whichever div is the largest. If I...
0
by: JamesBong | last post by:
So I am building something with divs that will be filled with dynamic data... so I dont know how tall the divs will be, but I want to make sure that div has a margin so the next div is 25px below the...
1
by: JamesBong | last post by:
I am building something with divs that will be filled with dynamic data... so I dont know how tall the divs will be, but I want to make sure that div has a margin so the next div is 25px below the...
1
by: Edward | last post by:
I created a simple CSS layout (code and example below) for bloggin/writing but ran into five issues that I need help with: 1. How do I get rid of the right-margin red line on the last three...
19
by: Edward | last post by:
Why is it when I have a DOCTYPE line in my HTML then "margin" and "padding" are ignored? This happens in both inline and stylesheet styles. It happens for both XHTML and HTML doctypes. It...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.