Forum Moderators: not2easy
What I have is something like this in my htm page:
<DIV><A href"#">Main</A></DIV><LI><a href="#">Item</a><UL><LI><a href="#">Item2</a></LI>
<LI><a href"#">Item3</a></LI>
</UL></LI>
And a css file like this:
#nav {
FLOAT:left;
MARGIN: 0px;
WIDTH:100%;
text-align: center;
LINE-HEIGHT: 1;
PADDING-TOP: 0px;
LIST-STYLE-TYPE: none;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
background-image: url(fotos/midbkg.gif);
background-repeat: repeat-x;
padding: 0px;
}#nav UL {PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; LINE-HEIGHT: 1; PADDING-TOP: 0px; LIST-STYLE-TYPE: none}
#nav A {PADDING-RIGHT: 0px; DISPLAY: block; PADDING-LEFT: 30px; PADDING-BOTTOM: 0px; COLOR: #fff; PADDING-TOP: 0px; TEXT-DECORATION: none}
#nav LI {
PADDING-RIGHT: 0px;
PADDING-LEFT: 10px;
FLOAT:left;
PADDING-BOTTOM: 0px;
PADDING-TOP: 7px;
HEIGHT: 20px;
background-repeat: no-repeat;
background-image: url(fotos/navlibkg.gif);
background-position: 22px 52%;
}
#nav LI A:hover {COLOR: #e7f14d}
#nav A:hover {COLOR: #476690}
#nav LI UL {LEFT: -999em; MARGIN: 7px 0px 0px -1.5em; WIDTH: 140px; POSITION: absolute; HEIGHT: auto}
#nav UL LI {BACKGROUND-POSITION: 0% 0%; BACKGROUND-ATTACHMENT: scroll; BACKGROUND-IMAGE: none; BACKGROUND-REPEAT: repeat}
#nav LI LI {PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; WIDTH: 140px; LINE-HEIGHT: 160%; PADDING-TOP: 0px; HEIGHT: auto}
#nav LI UL A {BORDER-RIGHT: #fff 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #fff 1px solid; PADDING-LEFT: 3px; BACKGROUND: #77AB44; PADDING-BOTTOM: 0px; BORDER-LEFT: #fff 1px solid; WIDTH: 137px; PADDING-TOP: 0px; BORDER-BOTTOM: #fff 1px; HEIGHT: auto}
#nav LI UL A:hover {COLOR: white; BACKGROUND-COLOR: #a3c3d8}
#nav LI UL UL {MARGIN: -1.9em 0px 0px 11.8em; WIDTH: 140px}
#nav LI:hover UL UL {LEFT: -999em}
#nav LI:hover UL UL UL {LEFT: -999em}
#nav LI.sfhover UL UL {LEFT: -999em}
#nav LI.sfhover UL UL UL {LEFT: -999em}
#nav LI:hover UL {LEFT: auto}
#nav LI LI:hover UL {LEFT: auto}
#nav LI LI LI:hover UL {LEFT: auto}
#nav LI.sfhover UL {LEFT: auto}
#nav LI LI.sfhover UL {LEFT: auto}
#nav LI LI LI.sfhover UL {LEFT: auto}
#nav LI:hover {POSITION: static}
#nav LI.hover {POSITION: static}
I'd like to add items like "Item 1b" or "Item 2b" but I guess that css need a twek to do so and also add some code in htm page (perhaps a class="subitem" to LI?)
May you help me?
#nav LI UL {LEFT: -999em; MARGIN: 7px 0px 0px -1.5em; WIDTH: 140px; POSITION: absolute; HEIGHT: auto}
Wouldn't be enoguh to define a
#nav LI UL UL {LEFT: -999em; MARGIN: 7px 0px 0px -1.5em; WIDTH: 140px; POSITION: absolute; HEIGHT: auto}
?
Problem: in IE 7 the subitems shows but shifted to the left some 200 pixels.
In Firefox shows almost good, but it would be nice the subitems starts aligned in vertical with the "item" instead begin placed higher as it is now.
html code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html><head><title>Probando</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT src="script.js" type=text/javascript></SCRIPT><link href="styles2.css" rel="stylesheet" type="text/css"><link href="nav.css" rel="stylesheet" type="text/css"></head><body><div id="travel"><div id="angelfalls"><div id="destination-content">
<h1>Test Page Title Here Please </h1>
<h2>Un texto que sea bien bien bien larguisimo </h2>
</div></div><div id="hotels"><div id="hotels-content">
<h2>Un texto que sea bien bien bien larguisimo <br>
Un texto que sea bien bien bien larguisimo </h2>
</div></div></div>
<ul id=nav>
<li>
<!-- Home -->
<div><a href="/argentina-brazil-hotels.htm">Bla</a></div><!-- Argentina -->
<li><a href="/argentina-brazil-hotels.htm#argentina">Has levels</a>
<ul>
<li><a href="/hotels-in-bariloche.htm">Item</a>
<ul>
<li><a href="#">Subitem1</a></li>
<li><a href="#">Subitem2</a></li>
</ul></li>
</ul>
</li>
</ul>
<div style="clear:both"></div>
CSS code for nav:
#nav {
FLOAT:left;
MARGIN: 0px;
WIDTH:100%;
text-align: center;
LINE-HEIGHT: 1;
PADDING-TOP: 0px;
LIST-STYLE-TYPE: none;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
background-image: url(fotos/midbkg.gif);
background-repeat: repeat-x;
padding: 0px;
}#nav UL {PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; LINE-HEIGHT: 1; PADDING-TOP: 0px; LIST-STYLE-TYPE: none}
#nav A {PADDING-RIGHT: 0px; DISPLAY: block; PADDING-LEFT: 30px; PADDING-BOTTOM: 0px; COLOR: #fff; PADDING-TOP: 0px; TEXT-DECORATION: none}
#nav LI {
PADDING-RIGHT: 0px;
PADDING-LEFT: 10px;
FLOAT:left;
PADDING-BOTTOM: 0px;
PADDING-TOP: 7px;
HEIGHT: 20px;
background-repeat: no-repeat;
background-image: url(fotos/navlibkg.gif);
background-position: 22px 52%;
}
#nav LI A:hover {COLOR: #e7f14d}
#nav A:hover {COLOR: #476690}
#nav LI UL {LEFT: -999em; MARGIN: 7px 0px 0px -1.5em; WIDTH: 140px; POSITION: absolute; HEIGHT: auto}
#nav UL LI {BACKGROUND-POSITION: 0% 0%; BACKGROUND-ATTACHMENT: scroll; BACKGROUND-IMAGE: none; BACKGROUND-REPEAT: repeat}
#nav LI LI {PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; WIDTH: 140px; LINE-HEIGHT: 125%; PADDING-TOP: 0px; HEIGHT: auto}
#nav LI UL A {BORDER-RIGHT: #fff 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #fff 1px solid; PADDING-LEFT: 3px; BACKGROUND: #77AB44; PADDING-BOTTOM: 0px; BORDER-LEFT: #fff 1px solid; WIDTH: 137px; PADDING-TOP: 0px; BORDER-BOTTOM: #fff 1px; HEIGHT: auto}
#nav LI UL A:hover {COLOR: white; BACKGROUND-COLOR: #a3c3d8}
#nav LI UL UL {MARGIN: -1.9em 0px 0px 11.8em; WIDTH: 140px}
#nav LI:hover UL UL {LEFT: -999em}
#nav LI:hover UL UL UL {LEFT: -999em}
#nav LI.sfhover UL UL {LEFT: -999em}
#nav LI.sfhover UL UL UL {LEFT: -999em}
#nav LI:hover UL {LEFT: auto}
#nav LI LI:hover UL {LEFT: auto}
#nav LI LI LI:hover UL {LEFT: auto}
#nav LI.sfhover UL {LEFT: auto}
#nav LI LI.sfhover UL {LEFT: auto}
#nav LI LI LI.sfhover UL {LEFT: auto}
#nav LI:hover {POSITION: static}
#nav LI.hover {POSITION: static}
May anybody help?
Problem: in IE 7 the subitems shows but shifted to the left some 200 pixels.
remove
text-align: center from the #nav rule and add it to #nav a instead - IE is positioning the drops by aligning to the center of the <li> - doing the above this will make IE happy as the left(default) alignment will still be present on the li. it would be nice the subitems starts aligned in vertical with the "item" instead begin placed higher as it is now.
change
#nav LI:hover {POSITION: static}
#nav LI.hover {POSITION: static} to
#nav LI:hover, #nav LI.hover {position: relative;} then change
#nav LI UL UL {MARGIN: -1.9em 0px 0px 11.8em; WIDTH: 140px} to
#nav li ul ul {top: 0; margin: 0 0 0 140px; width: 140px;} it's the negative top margin which is moving the sub menus up, and instead of guessing the height of the li you can use the top positioning, but you have to make the containing <li> position: relative so the drop knows what "top" you're speaking about.
You could just play around with negative top margin to make it more suitable, but it will not be perfect x-browser because the line-height of the <li> will vary by a pixel or two depending on font size.
Suzy