Forum Moderators: not2easy

Message Too Old, No Replies

positioning problems

simple layout not behaving well

         

sldesigns

4:57 am on Jun 17, 2005 (gmt 0)

10+ Year Member



I'm trying to set up a simple page, with 5 basic divs. One sets on top of the others, and that one works well (absolute positioning here). IE displays the rest most like my vision, but with a gap on div2 that affects divs3 and 4. FF throws a large gap at the top, which pushes everything down except the text in that div.

Reading and trying different positioning hasn't helped . . . for some reason I don't want to absolutely position everything. Any ideas?

Here's the css:

 body {
margin: 0;
padding: 0;
}
#contain {
position: relative;
width: 100%;
}
/* layout
--------------*/
#top {
height: 100px;
width: 100%;
background-color: #898741;
}
#bkgrnd1 {
height: 300px;
width: 100%;
background-image: url(images/colorsb.jpg);
}
#box4 {
height: 116px;
width: 413px;
background-color: #676900;
float: left;
}
#btm {
height: 200px;
width: 100%;
background-color: #898741;
}
#homemain {
position: absolute;
top: 45px;
left: 413px;
width: 373px;
height: 471px;
background-color: #e9b97f;
border: 1px solid #FFFFFF;
}
/* text
--------------*/
p {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: .8em;
line-height: 1.4em;
}
.homelink1 {
margin-top: 70px;
margin-left: 200px;
color: #fff;
}
.homelink2 {
margin-top: 120px;
margin-left: 437px;
color: #fff;
}
#homemain p {
margin: 24px 24px 12px;
}

and the html:


<?xml version="1.0" encoding="iso-8859-1"?>
<!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>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="design2css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="contain">
<div id="top">
<p class="homelink1">expertise ¦ past work ¦ bio </p>
</div>
<div id="bkgrnd1"> &nbsp;</div>
<div id="box4"> </div>
<div id="btm">
<p class="homelink2"> about ¦ partners ¦ contact </p>
</div>
<div id="homemain">
<p>markit strategies and PR is an integrated strategic marketing and public
relations firm serving a wide range of industries with marketing, communications,
business development, and media relations program development. We can assist
organizations with strategic market development, writing and establishing
productive relationships with the media.</p>
</div>
</div>
</body>
</html>

createErrorMsg

10:27 am on Jun 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your gaps, especially the one at the top of the page in FF, are margin related. The top margins you set on your #homelink and #homelink2 paragraphs to push them down from the top are collapsing [w3.org] with the div margins. When this happens, the combined (collapsed) margin for the two elements (parent and child) displays outside of the parent, causing the gap. Swap out padding-top for margin-top and things should render the way you want (padding on the paragraph will stay inside the parent).

The large top margin on #homelinks2 is causing a large gap between the bottom of your content div and the text for those links in IE. I would remove it altogether. You'll also note that this gets rid of the small white gap between the bottom div and the others in FF.

A final note: the floated #box4 div does not extend behind the abs pos #homemain div, leaving a white space on the right side of the layout. Making #box4's width 100% solves this, if it's an unintentional result.

cEM

sldesigns

3:53 pm on Jun 17, 2005 (gmt 0)

10+ Year Member



Padding worked perfectly! I read the css link you provided--I always think I understand this stuff, but I'm not really.

SO, the boxes fit well, but there is still a funny white space above the #bkgrnd1 div, that also affects #box4 in IE, not FF.

By the way, #box4 is intentional. It is empty now, but will have content on other pages, and I didn't want to show on the right side of the main content (#homemain) box.

Margins, paddings (set to 0), floating, display properties haven't had an effect. It's probably something obvious to you, but frequently the obvious escapes me. Your help is greatly appreciated!

the css:

body {
margin: 0;
padding: 0;
}
#contain {
position: relative;
width: 100%;
}
/* layout
--------------*/
#top {
height: 100px;
width: 100%;
background-color: #898741;
}
#bkgrnd1 {
height: 300px;
width: 100%;
background-image: url(images/colorsb.jpg);'
}
#box4 {
height: 116px;
width: 413px;
background-color: #676900;
float: left;
}
#btm {
height: 200px;
width: 100%;
background-color: #898741;
}
#homemain {
position: absolute;
top: 45px;
left: 413px;
width: 373px;
height: 471px;
background-color: #e9b97f;
border: 1px solid #FFFFFF;
}
/* text
--------------*/
p {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: .8em;
line-height: 1.4em;
}
.homelink1 {
padding-top: 70px;
padding-left: 200px;
color: #fff;
}
#btmlinks p {
color: #fff;
}
#homemain p {
padding: 24px 24px 12px;
}

and the html:


<?xml version="1.0" encoding="iso-8859-1"?>
<!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>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="design2css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="contain">
<div id="top">
<p class="homelink1">expertise ¦ past work ¦ bio </p>
</div>
<div id="bkgrnd1"> &nbsp;</div>
<div id="box4"> </div>
<div id="btm">
</div>
<div id="homemain">
<p>main content area</p>
</div>
</div>
</body>
</html>

sldesigns

10:19 pm on Jun 17, 2005 (gmt 0)

10+ Year Member



Got it! found an old post for this very issue. Added to the css for the top two boxes to font-size: 0. Links still look proper, and works in IE. Brilliant!

sldesigns

2:11 am on Jun 18, 2005 (gmt 0)

10+ Year Member



never mind. Didn't work. I took out the font-size thing, and put upper links into an absolutely positioned div on top of the top colored div.
Line-height changed the font rendering to be smaller in IE and disappear in FF.

drhowarddrfine

4:25 am on Jun 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Remove the first line of your doctype. The xml prolog. This does not work for FF and sends IE goes into quirks mode.