...

View Full Version : css list navigation problems



ch4sethe5un
07-17-2008, 02:01 AM
I can't figure this out... :confused:

I'm trying to make a navigation with lists, but i cant get it to display correctly.

The nav bar looks the way i WANT it to look in FF, but in IE it looks the way i EXPECTED it to look with the code. and expression web doesn't look like either (so, I'm constantly previewing).

The main problem is that the divs in FF are overlapping and i can't figure out why, HELP?


<!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>ch4sethe5un</title>

<style type="text/css">
html, body{
margin:0;
padding:0;
}
#navcontainer{
width: 800px;
height: 30px;
}
#navcontainer ul
{
padding-left: 0;
margin-left: 0;
background-color:#000;
float: left;
font-family: arial, helvetica, sans-serif;
}

#navcontainer ul li { display: inline; }

#navcontainer ul li a
{
color: White;
text-decoration: none;
float: left;
text-align: center;
width: 160px;
height: 30px;
padding-top: 5px;
}
#navcontainer ul li a:hover
{
background-color: #0066CC;
color: #fff;
height: 30px;
}
#dirHeader{
background-color: #0099CC;
height: 30px;
width: 800px;
}
</style>

</head>


<body>
<div id="wrapper">
<div id="navcontainer">
<ul id="navlist">
<li><a href="#">Item one</a></li>
<li><a href="#">Item two</a></li>
<li><a href="#">Item three</a></li>
<li><a href="#">Item four</a></li>
<li><a href="#">Item five</a></li>
</ul>
</div>
<div id="dirHeader">
</div>
</div>

</body>

</html>

bazz
07-17-2008, 02:47 AM
Hi,

I found in ff that it was completely horizontal but that in IE 6, item 5 was on a new line until hover, when it all wnet onto the one line.

Try


* {
padding:0;
margin : 0;
border:0;
}


instead of


html, body{
margin:0;
padding:0;
}


bazz

ch4sethe5un
07-17-2008, 03:27 AM
Hi,
I found in ff that it was completely horizontal but that in IE 6, item 5 was on a new line until hover, when it all wnet onto the one line.


Thank you, that fixed it a little bit (less severe overlap), but in FF the first div is still overlapping the second ~5px.

Also could you explain what you typed in the quote earlier, i don't quite understand it?

bazz
07-17-2008, 03:29 AM
Yup, I used the universal selector '*' wiht the attributes inside the {}. That means that everything in the page is assigned the value of 0 to border, padding and margin.

I'll look again at the divs and see, if by adding a background color, I can see what you mean. It looks fine, to me in FF3 and IE6.

bazz

bazz
07-17-2008, 03:42 AM
Yeh I found the cause of the overlap.



#navcontainer ul li a
{
color: White;
text-decoration: none;
float: left;
text-align: center;
width: 160px;
height: 30px;
padding-top: 5px;
}

Your nav_container is assigned 30px of height.
The total height of the a link, is 35px, wich means it displays lower than the bottom edge of the div. And by displaying lower than the bottom of the div, it hides the top 5px of the next div.

solution: either add 5px to your nav_container or remove the 5px padding from the link OR add a margin-top:5px to the dirHeader div.

bazz

ch4sethe5un
07-17-2008, 03:58 AM
Yeh I found the cause of the overlap.

Your nav_container is assigned 30px of height.
The total height of the a link, is 35px, wich means it displays lower than the bottom edge of the div. And by displaying lower than the bottom of the div, it hides the top 5px of the next div.

solution: either add 5px to your nav_container or remove the 5px padding from the link OR add a margin-top:5px to the dirHeader div.

bazz

Thanks for the help. :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum