Solved

Gaps between header, content and footer divs in Firefox

Posted on 2007-12-01
8
943 Views
Last Modified: 2013-12-07
Hi

I'm trying to convert my table design to CSS tableless; so far I've managed to get the main content div & background image to expand down as needed. It looks right in IE but there are gaps between the header div/content div in Firefox when I use <p> tags and <h1> tags, and there's also a gap between the content div and the footer div that I don't know how to get rid of. Can someone please take a look and maybe help me figure this out? the page is here: www. angelsaffordablewebdesign.com/web-design-div.htm . The css is included in the page code. Thank you!!
0
Comment
Question by:Angelz22
  • 5
  • 3
8 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 20390211
As always, when a page is rendered differently in IE and Firefox, Firefox gets it right.

The gaps you see comes from margin-collapsing:

http://www.researchkitchen.de/blog/archives/css-autoheight-and-margincollapsing.php

As the header and paragraph tags have a margin by default, this margin will extend outside the parent element, so that there will be a margin between your containing divs.

The solution is simple; use padding instead. Like:

h1, p { margin: 0; padding: 5px 0; }
0
 

Author Comment

by:Angelz22
ID: 20390225
Thank you, GreenGhost, that corrected the problem with the gap between the header div and the content div, but I am still having the problem with the gap between the content div and the footer div; also, is it possible to set the padding in the content div without wrecking the design, so I do not have to use a separate div within the content div like I'm doing now? Thank you!
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20390902
I was going to take a look at the html code, but I quickly gave up when I saw it... It's virtually unreadable, how do you maintain code like that?

Anyhow, an extra div is one way of handling margin-collapsing, but it's not the only way.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:Angelz22
ID: 20391707
The code is more easily read now; sorry about that, I forgot; I'm so used to getting rid of extra white space. Frankly it's much easier for me to maintain the way it was, but I guess that's because I'm used to it. Anyway, if someone could help me figure this out it would be very much appreciated...thanks :)
0
 

Author Comment

by:Angelz22
ID: 20391775
Hmmm, I seem to have corrected the gaps issue; there is still an issue with setting the margins (padding?) within the div though. It's not a huge problem but I would rater be able to just set the left and right margins within the div itself so the text is aligned where it currently is without having to use an extra div for that-any suggestions?
0
 

Author Closing Comment

by:Angelz22
ID: 31412153
Thanks! still have the other question but that wasn't part of the original question and you did help me figure this out :)
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20391872
When I look at the code it still looks horrible, but now I realise where it comes from. I use "Edit HTML" in Devloper Toolbar, and then I also get the html code that your navigation scripts write, and that is what makes it unreadable. The rest of it doesn't look that bad.

If you add padding to an element, that adds to the specified size. When you add horisontal padding you have to reduce the width to keep the total size the same. Do like this in the #web-design-3 class, and you don't need another div inside it:

padding: 0 67px 0 70px;
width:743px;
0
 

Author Comment

by:Angelz22
ID: 20391950
Beautiful, thank you so much!!!
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

825 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