PDA

View Full Version : Gap at Top


AlexC
09-03-2010, 05:18 PM
How do I eliminate the gap between the container and the top of the page?
Thanks

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 100%;
background-color: #666666;
}
.twoColFixRtHdr #container {
width: 1000px; /* the auto margins (in conjunction with a width) center the page */
border: 1px none #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
margin-top: 0px;
margin-right: auto;
margin-bottom: 0;
margin-left: auto;
background-color: #999999;
padding-top: 0px;
}
.twoColFixRtHdr #sidebar1 {
float: right; /* since this element is floated, a width must be given */
width: 200px;
background-color: #CCCCCC;
margin-top: 20px;
padding-top: 15px;
padding-right: 10px;
padding-bottom: 15px;
padding-left: 10px;
}
.twoColFixRtHdr #mainContent {
margin-top: 0;
margin-right: 250px;
margin-bottom: 0;
margin-left: 0;
padding-top: 0px;
padding-right: 20px;
padding-bottom: 0;
padding-left: 20px;
}
.twoColFixRtHdr #footer {
padding: 0 10px 0 20px;
}
.twoColFixRtHdr #footer p {
margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
}
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page */
float: left;
margin-right: 8px;
}
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
-->
</style>
<!--[if IE 5]>
<style type="text/css">
/* place css box model fixes for IE 5* in this conditional comment */
.twoColFixRtHdr #sidebar1 { width: 220px; }
</style>
<![endif]--><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.twoColFixRtHdr #sidebar1 { padding-top: 30px; }
.twoColFixRtHdr #mainContent { zoom: 1; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]--></head>

<body class="twoColFixRtHdr">

<div id="container">
<div id="sidebar1">
<table width="200" border="0" cellspacing="0" cellpadding="10">
<tr>
<td>home</td>
</tr>
<tr>
<td>about</td>
</tr>
<tr>
<td>yoga</td>
</tr>
</table>
<br />
<table width="200" height="110" border="2" cellpadding="10" cellspacing="0">
<tr bordercolor="#999966">
<td><p>&nbsp;</p>
<p>&nbsp;</p></td>
</tr>
</table>
<br />
<table width="200" height="109" border="2" cellpadding="10" cellspacing="0" bordercolor="#999966">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<!-- end #sidebar1 --></div>
<div id="mainContent">
<h1> Laura Storz</h1>
<p><img name="" src="" width="703" height="303" alt="" style="background-color: #000000" /></p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam, justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis ligula. Phasellus tristique purus a augue condimentum adipiscing. </p>
<h3>H2 level heading </h3>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam, justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam ante ac quam. Maecenas urna purus.</p>
<!-- end #mainContent --></div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
<div id="footer">
<p>Footer</p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>

Rob_Che
09-13-2010, 10:06 PM
It's the default margin on the H1 tag "Laura Storz" that is pushing the div away from the page top...

I added style....

H1 {
margin: 0;
}


....and it cleared it.

Also - see if you can find a tutorial that uses divs rather than tables for your design - loads out there (http://www.google.com/search?source=ig&hl=en&rlz=1G1GGLQ_ENUK303&=&q=two+column+css+templates&aq=1&aqi=g10&aql=&oq=two+column+css&gs_rfai=)

Rob

AlexC
09-18-2010, 04:03 PM
I Rob. Thanks a lot for the tip. I really appreciate it!

I've been trying to find a good div tutorial but for whatever reason it's been extremely difficult. I just took a Dw college class to remedy this but unfortunately the instructor spent all her time on tables!! If you know of any solid tutorial on div positioning i would love to find one.

Thanks again.

DWcourse
09-19-2010, 02:28 AM
Here's a page that can get you started and demonstrates a lot of the possibilities: http://www.dwcourse.com/css-positioning.html

Corrosive
09-19-2010, 07:45 AM
I just took a Dw college class to remedy this but unfortunately the instructor spent all her time on tables!!

I'd ask for your money back :wink: I can't believe anyone would even start to teach tables for layout let alone a whole class!

DWcourse
09-19-2010, 04:26 PM
<rant>You have to check out college classes about web topics carefully before signing up. The best are generally taught by people who are active, professional web designers/developers.

I one taught an "advanced" class. All the students had learned in their first class was how to slice a Photoshop file. They didn't even know how to upload the resulting page!

It's better now but I still hear about classes teaching table-based design with only a casual (if any) mention of CSS. A major problem is classes taught by profs who graduated when the Internet didn't exist and who aren't actively creating websites.</rant>

Anyway, that's why I started teaching online.