/    Sign up×
Community /Pin to ProfileBookmark

why is my poisitioning breaking in IE6?

Hi,
I normally develop sites using tables as a lot of sites are database and data driven… however I’m building some smaller sites now with css positioning.

So I’ve hit my first problem.

I have several nested divs for layout.. inside one is a UL list for the navigation.

Within each li is a span tag and a <a> tag.

The span tag contains an image for each li.. the span has a minus poisitioning value so that it falls back and upwards slightly from the rest of the contents of the li…

All fine so far…
However, in IE6, the span is getting a margin added to the bottom of a few tens of pixels.. making the navigation div far too high.

If I remove the margin using a negative value that works fine but then other bits and pieces are thrown out and it no longer works in IE7 and FF.

I’ve pasted up my code below.. any ideas?
Stylesheet:
body, html {
background-image: url(images/bg.jpg);
background-repeat: repeat-x;
background-position: top;
margin: 0px;
padding: 0px;
height: 100%;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
text-align: center;

}
#overallholder {
text-align: center;
margin: 0px;
padding: 0px;
width: 768px;
height: 100%;
margin-left: auto;
margin-right: auto;

}
#overallholder #leftshadow {
background-image: url(images/bg_leftshadow.jpg);
width: 4px;
float: left;
height: 100%;
}
#overallholder #maincontent {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #0157AC;
width: 760px;
background-color: #FFFFFF;
float: left;
height: 100%;
margin: 0px;
padding: 0px;
text-align: left;
}
#overallholder #maincontent #mainnav a {
color: #FFFFFF;
text-decoration: none;
}

#overallholder #maincontent #header #headertxt {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #FFFFFF;
float: right;
text-align: right;
padding-right: 10px;
}
#overallholder #maincontent #mainnav {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #FFFFFF;
background-color: #669ECE;
height: 29px;
padding-right: 10px;
padding-left: 12px;
}
#overallholder #maincontent #mainnav ul {
margin: 0px;
padding: 0px;
list-style-type: none;
}
#overallholder #maincontent #mainnav li {
float: left;
position: relative;
padding-top: 6px;
font-weight: bold;
padding-right: 15px;
}
#overallholder #maincontent #mainnav span {
position: relative;
top: -18px;
float: left;
margin: 0px;
}

#overallholder #rightshadow {
background-image: url(images/bg_rightshadow.jpg);
width: 4px;
float: left;
height: 100%;
}
#overallholder #maincontent #header #leftimg {
float: left;
margin: 0px;
padding: 0px;
}

#overallholder #maincontent #header {
background-image: url(images/header_bg.jpg);
background-repeat: repeat-x;
height: 131px;
margin: 0px;
padding: 0px;
}

END OF STYLE SHEET

<!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=iso-8859-1″ />
<title>Title Here</title>
</head>

<body>
<div id=”overallholder”>
<div id=”leftshadow”></div>
<div id=”maincontent”>
<div id=”header”>
<img src=”images/header_left.jpg” alt=”” width=”543″ height=”131″ id=”leftimg” />
<div id=”headertxt”><b>ADDRESS HERE</b><br />
</div>
</div>
<div id=”mainnav”>
<ul>
<li><span><img src=”images/nav_home.gif” width=”62″ height=”68″ /></span><a href=”index.asp”>HOME</a></li>
<li><span><img src=”images/nav_aboutus.gif” width=”62″ height=”68″ /></span><a href=”aboutus.asp”>ABOUT US</a></li>
<li><span><img src=”images/nav_products.gif” width=”62″ height=”68″ /></span><a href=”products.asp”>PRODUCTS</a></li>
<li><span><img src=”images/nav_news.gif” width=”62″ height=”68″ /></span><a href=”news.asp”>NEWS</a></li>
<li><span><img src=”images/nav_contacts.gif” width=”62″ height=”68″ /></span><a href=”contacts.asp”>CONTACTS</a></li>
</ul>

</div>
</div>
<div id=”rightshadow”></div>
</div>
</body>
</html>

file can be found at:
[url]www.patchworkmedia.co.uk/proof/safepat[/url]

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Sep 11.2007 — First of all, you don't need to write:
#overallholder #whatever #whatever{}
The whole point of an id is that there is only one element on the page with that id and you can reference it directly.

Secondly, you should remove <b></b> tags, and replace it either with <em> or <strong> or add
<i>
</i>font-weight:bold;

to #headertxt.

I also don't know why you bothered to put them in spans at all, when
<i>
</i>#mainnav ul li img {display:inline;whatever}

does the same.

You can leave out
<i>
</i>text-align: center;
margin: 0px;
padding: 0px;

from #overallholder as well, as it is inherited from html, body.

As an alternative, you could try adding a minus margin-top to the spans (or imgs in my example) to move it, which is what the w3c css validator error page does (http://jigsaw.w3.org/css-validator/validator?uri=a&warning=1&profile=css21&usermedium=all) to display "validator" over CSS.
Copy linkTweet thisAlerts:
@mtm81authorSep 12.2007 — thanks for the reply!

Some of the points you've raised are coded how dreamweaver has done it for me (the multi level ID's in the CSS and <b> tags), so I'll go and change that.

However I have figured it out by adding a minus padding to the LI tag as that is what what causing the problem in IE6.

It now validates correctly...
×

Success!

Help @mtm81 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...