Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-17-2008, 01:01 AM   PM User | #1
ch4sethe5un
New Coder

 
Join Date: Jul 2008
Posts: 71
Thanks: 7
Thanked 3 Times in 3 Posts
ch4sethe5un is an unknown quantity at this point
css list navigation problems

I can't figure this out...

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?

Code:
<!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>
ch4sethe5un is offline   Reply With Quote
Old 07-17-2008, 01:47 AM   PM User | #2
bazz
Master Coder

 
Join Date: Apr 2003
Location: in my house
Posts: 5,211
Thanks: 39
Thanked 201 Times in 197 Posts
bazz will become famous soon enoughbazz will become famous soon enough
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
Code:
* {
padding:0;
margin : 0;
border:0;
}
instead of
Code:
html, body{
	margin:0;
	padding:0;
}
bazz
__________________
"The day you stop learning is the day you become obsolete"! - my late Dad.

Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
Useful MySQL resource
Useful MySQL link
bazz is offline   Reply With Quote
Old 07-17-2008, 02:27 AM   PM User | #3
ch4sethe5un
New Coder

 
Join Date: Jul 2008
Posts: 71
Thanks: 7
Thanked 3 Times in 3 Posts
ch4sethe5un is an unknown quantity at this point
Quote:
Originally Posted by bazz View Post
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?
ch4sethe5un is offline   Reply With Quote
Old 07-17-2008, 02:29 AM   PM User | #4
bazz
Master Coder

 
Join Date: Apr 2003
Location: in my house
Posts: 5,211
Thanks: 39
Thanked 201 Times in 197 Posts
bazz will become famous soon enoughbazz will become famous soon enough
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
__________________
"The day you stop learning is the day you become obsolete"! - my late Dad.

Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
Useful MySQL resource
Useful MySQL link
bazz is offline   Reply With Quote
Users who have thanked bazz for this post:
ch4sethe5un (07-17-2008)
Old 07-17-2008, 02:42 AM   PM User | #5
bazz
Master Coder

 
Join Date: Apr 2003
Location: in my house
Posts: 5,211
Thanks: 39
Thanked 201 Times in 197 Posts
bazz will become famous soon enoughbazz will become famous soon enough
Yeh I found the cause of the overlap.

Code:
#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
__________________
"The day you stop learning is the day you become obsolete"! - my late Dad.

Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
Useful MySQL resource
Useful MySQL link
bazz is offline   Reply With Quote
Users who have thanked bazz for this post:
ch4sethe5un (07-17-2008)
Old 07-17-2008, 02:58 AM   PM User | #6
ch4sethe5un
New Coder

 
Join Date: Jul 2008
Posts: 71
Thanks: 7
Thanked 3 Times in 3 Posts
ch4sethe5un is an unknown quantity at this point
Quote:
Originally Posted by bazz View Post
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.
ch4sethe5un is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 04:44 AM.


Advertisement
Log in to turn off these ads.