Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Old 02-19-2010, 01:45 AM Gap Between Divs
Junior Talker

Posts: 2
Trades: 0
Both my css and html check out on the w3 validator, yet I am having trouble with a vertical gap (about 15 px in height) between my "navigation" div and "body" div (and, most likely, the same problem will occur when I get to working on my "footer" div).

This has happened to me a number of times before, and I usually just set up a negative margin (though it's something I do not want to do again). Is there a way to fix this problem without any "hacks" or negative margins?

Here's my HTML code:

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
   <link rel="stylesheet" type="text/css" href="styles.css" />
   <title>Title</title>
</head>

<body>
   <div class="container">
      <div class="header">
         <img src="images/header.png" width="800" height="150" alt="Header" title="Header" />
      </div>
      <div class="navigation">
         <div class="navbar">
            <div class="navlink"><a href="index.html">Home</a></div>
            <div class="navlink"><a href="updates.html">Updates</a></div>
            <div class="navlink"><a href="inventory.html">Inventory</a></div>
            <div class="navlink"><a href="contact.html">Contact</a></div>
         </div>
      </div>
      <div class="body">
         <div class="motto">
            <h1>Motto</h1>
         </div>
         <div class="content">
            <p>Testing. Testing. Testing.</p>
         </div>
      </div>
      <div class="footer">
         <p>Testing. Testing. Testing.</p>
      </div>
   </div>
</body>

</html>
And here's my CSS code:

Code:
body {
   font-family: arial, sans-serif;
   background-color: #1a6dea;
}

.container {
   width: 950px;
   margin-left: auto;
   margin-right: auto;
}

.header {
   width: 800px;
   height: 150px;
   margin-top: 25px;
   margin-left: auto;
   margin-right: auto;
}

.navigation {
   width: 950px;
   height: 100px;
   background-color: #fbfbfb;
}

.navbar {
   width: 800px;
   margin-top: 50px;
   margin-left: auto;
   margin-right: auto;
}

.navlink {
   width: 150px;
   float: left;
   position: relative;
   margin-left: 25px;
   margin-right: 25px;
   text-align: center;
}

.navlink a:link, a:active, a:visited {
   display: block;
   font-size: 30px;
   color: #333333;
   text-decoration: none;
}

.navlink a:hover {
   display: block;
   text-align: center;
   font-size: 30px;
   color: #de431f;
   text-decoration: none;
}

.body {
   width: 950px;
   background-color: #fbfbfb;
}

/*-----------------------------CLEARFIX-----------------------------*/

/* thanks to perishable press (http://perishablepress.com/) for this great clearfix method */

.navigation:after {
	visibility: hidden;
	display: block;
	font-size: 0;
	content: " ";
	clear: both;
	height: 0;
}

.navigation {
	display: inline-block;
}
Thanks in advance.
nineball537 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-19-2010, 02:36 AM Re: Gap Between Divs
YoshiGoneMad's Avatar
Novice Talker

Posts: 7
Trades: 0
Add this to your .css

Code:
h1
{
margin:0;
padding:0;
}
By default, margins are added to headings. Hope that helps.
YoshiGoneMad is offline
Reply With Quote
View Public Profile
 
Old 02-19-2010, 12:58 PM Re: Gap Between Divs
orionoreo's Avatar
Ultra Talker

Posts: 335
Name: Jerry
Trades: 0
i start my css

Code:
* {
margin: 0px;
padding: 0px;
}
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
orionoreo is offline
Reply With Quote
View Public Profile
 
Old 02-21-2010, 01:27 AM Re: Gap Between Divs
Junior Talker

Posts: 2
Trades: 0
Margins are a pain ... However, in this case, I found they were completely unrelated. When I fudged with my clearfix method, the problem straightened itself out. Darn divs.

Thanks for the help, fellas.
nineball537 is offline
Reply With Quote
View Public Profile
 
Old 02-24-2010, 07:04 AM Re: Gap Between Divs
Banned

Posts: 3
Name: Jeck Martin
Trades: 0
When I add a background-color to both your divs, they do touch, so I guess one of them is taller than you think (perhaps due to your background image).
jeck143 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Gap Between Divs
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.42355 seconds with 12 queries