/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] More CSS Suckerfish Menu problems

Hi All,

I am still having problems with getting this menu working exactly like I want it to.

I’ve asked for different things in two different threads before. The first was getting 2 images to use as my background color for my menu (see thread [URL=”http://www.webdeveloper.com/forum/showthread.php?t=172855″]here[/URL]). The second was getting a second image (2 images again) to be used as my hover image for the menu (see thread [URL=”http://www.webdeveloper.com/forum/showthread.php?t=173002″]here[/URL]).

Now my current problem is, with the information I got from the above two threads, I had (I thought) enough information to get the menu done. The background images and the hover images were working on the parent menu item, but I also wanted to have them on the sub level menu items. I’ve gotten it almost right, but I just can’t finish it (probably a much better way to do it anyways).

I have the background images working on the sub level menus, and I can get the left hover image working on hover, I just can’t get the right image working properly. I have it attached and can see it, but it aligns to the right of the menu text, not the <li> that the text is positioned in. Can anyone help me to figure out what I am doing wrong? I’ve tried moving my tags around and switching which tags the images are attached to and nothing, this is the closest I can get with it.

[B]HTML Page[/B]

[CODE]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<title>Untitled Document</title>
<script type=”text/javascript” src=”sfhover.js”></script>
<link rel=”stylesheet” type=”text/css” href=”multimenuvert.css”>
</head>

<body>
<ul id=”vertnav”>
<li><div class=”toplev”><a href=”#” >first Level menu</a></div>
<ul>
<li><div class=”sublev”><a href=”#” ><span class=”tohover”>second Level menu</span></a></div></li>
<li><div class=”sublev”><a href=”#” ><span class=”tohover”>second Level menu</span></a></div>
<ul>
<li><div class=”sublev”><a href=”#” ><span class=”tohover”>third Level menu</span></a></div></li>
</ul>
</li>
</ul>
</li>
<li><div class=”toplev”><a href=”#” >fourth Level menu</a></div>
<ul>
<li><a href=”#” >fifth Level menu</a></li>
<li><a href=”#” >fifth Level menu</a>
<ul>
<li><a href=”#” >sixth Level menu</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</body>
</html>[/CODE]

[B]CSS Page[/B]

[CODE]#vertnav{
padding:0;
margin:0;
list-style: none;
width: 12em;
}
#vertnav li {
margin:0;
position: relative;
width: 12em;
background-color:gray;
border:solid 1px white;
border-bottom:none;
padding: 0em;
}

#vertnav li:last-child{border-bottom:1px solid #CCC;}

#vertnav a {
text-decoration:none;
display:block;
height:1em;
line-height: 1em;
padding: 0.1em;
}

#vertnav a:link, a:visited, a:active {
Color: Red;
}
#vertnav a:hover {
Color: White;
}
#vertnav .toplev {
background-image: url(test_menu/button-left.jpg);
background-repeat: no-repeat;
background-position: left center;
}
#vertnav .toplev a {
background-image: url(test_menu/button-right.jpg);
background-repeat: no-repeat;
background-position: right center;
text-align: center;
}
#vertnav li:hover .toplev, #vertnav li.over .toplev {
background-image: url(test_menu/buttonOver-left.jpg);
}
#vertnav li:hover .toplev a, #vertnav li.over .toplev a {
background-image: url(test_menu/buttonOver-right.jpg);
color: #FFFFFF;
}

#vertnav .sublev {
background-image: url(test_menu/button-left.jpg);
background-repeat: no-repeat;
background-position: left center;
}
#vertnav .sublev a {
background-image: url(test_menu/button-right.jpg);
background-repeat: no-repeat;
background-position: right center;
text-align: center;
}

#vertnav .sublev a:hover {
background-image: url(test_menu/buttonOver-left.jpg);
}
#vertnav .sublev a:hover .tohover{
background-image: url(test_menu/buttonOver-right.jpg);
background-repeat: no-repeat;
background-position: right center;
color: #FFFFFF;

}

#vertnav ul {
list-style: none;
width:12em;
position:absolute;
left: -999em;
top: 0px;
margin: 0;
padding: 0;
}
#vertnav li:hover ul ul, #vertnav li:hover ul ul ul,
#vertnav li:hover ul ul ul ul, #vertnav li:hover ul ul ul ul ul,
#vertnav li.over ul ul, #vertnav li.over ul ul ul,
#vertnav li.over ul ul ul ul, #vertnav li.ver ul ul ul ul ul {
left: -999em;
}
#vertnav li:hover ul, #vertnav ul li:hover ul, #vertnav ul ul li:hover ul,
#vertnav li.over ul, #vertnav ul li.over ul, #vertnav ul ul li.over ul {
left: 12em;
}
* html #vertnav li {
float: left;
}[/CODE]

My goal is to have the images and hover images applied to the entire menu (parent and sub, and sub sub levels), I am just working my way up to limit my errors to a manageable number.

And if you want to see the images that I am using, they are attached to the first post on the second link above. I didn’t want to post the same images yet again when they are right there.

Thanks,
Jeremy

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@CentauriFeb 19.2008 — I notice you have removed the <li> padding that was used in the previous threads, thereby removing the grey (yellow on hover) background surrounding each button. As such, the left images can be applied to the <li> itself, and the nested div inside each <li> is no longer required. As the images are required on each level, there is also no need to segregate the top level with the class name, so the classes can also go. The menu html can now be :[CODE]<ul id="vertnav">
<li><div><a href="#" >first Level menu</a></div>
<ul>
<li><div><a href="#" >second Level menu</a></div></li>
<li><div><a href="#" >second Level menu</a></div>
<ul>
<li><div><a href="#" >third Level menu</a></div></li>
</ul>
</li>
</ul>
</li>
<li><div><a href="#" >fourth Level menu</a></div>
<ul>
<li><div><a href="#" >fifth Level menu</a></div></li>
<li><div><a href="#" >fifth Level menu</a></div>
<ul>
<li><div><a href="#" >sixth Level menu</a></div></li>
</ul>
</li>
</ul>
</li>
</ul>[/CODE]


Like the mucking around with the comma-separated rules to make sure the correct level <ul>s are displayed or hidden, a similar method is required to make sure the correct level button rollover images are dispalyed - which can get a little confusing.... The amended css I came up with is :[CODE]#vertnav{
padding:0;
margin:0;
list-style: none;
width: 12em;
}
#vertnav li {
margin:0;
position: relative;
width: 12em;
border:solid 1px white;
border-bottom:none;
padding: 0;
background-image: url(images/button-left.jpg);
background-repeat: no-repeat;
background-position: left center;
}

#vertnav li:last-child{border-bottom:1px solid #CCC;}

#vertnav a {
text-decoration:none;
display:block;
height:1em;
line-height: 1em;
padding: 0.1em;
color: red;
background-image: url(images/button-right.jpg);
background-repeat: no-repeat;
background-position: right center;
text-align: center;
}
#vertnav li:hover li, #vertnav li.over li,
#vertnav li:hover li li, #vertnav li.over li li {
background-image: url(images/button-left.jpg);
}
#vertnav li:hover li a, #vertnav li.over li a,
#vertnav li:hover li li a, #vertnav li.over li li a {
background-image: url(images/button-right.jpg);
color: red;
}
#vertnav li:hover, #vertnav li.over,
#vertnav ul li:hover, #vertnav ul li.over,
#vertnav ul ul li:hover, #vertnav ul ul li.over {
background-image: url(images/buttonOver-left.jpg);
}
#vertnav li:hover a, #vertnav li.over a,
#vertnav ul li:hover a, #vertnav ul li.over a,
#vertnav ul ul li:hover a, #vertnav ul ul li.over a {
background-image: url(images/buttonOver-right.jpg);
color: #FFFFFF;
}
#vertnav ul {
list-style: none;
width:12em;
position:absolute;
left: -999em;
top: 0px;
margin: 0;
padding: 0;
}
#vertnav li:hover ul ul, #vertnav li:hover ul ul ul,
#vertnav li:hover ul ul ul ul, #vertnav li:hover ul ul ul ul ul,
#vertnav li.over ul ul, #vertnav li.over ul ul ul,
#vertnav li.over ul ul ul ul, #vertnav li.ver ul ul ul ul ul {
left: -999em;
}
#vertnav li:hover ul, #vertnav ul li:hover ul, #vertnav ul ul li:hover ul,
#vertnav li.over ul, #vertnav ul li.over ul, #vertnav ul ul li.over ul {
left: 12em;
}
* html #vertnav li {
float: left;
}
[/CODE]
Copy linkTweet thisAlerts:
@jdgauthorFeb 20.2008 — Well yet again, you have solved my issue perfectly Centauri. Thank you very much.

Jeremy
×

Success!

Help @jdg 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...