/    Sign up×
Community /Pin to ProfileBookmark

Nested List Menu – No JavaScripting

I am rather new to CSS and have never worked with anything like this before. I am having trouble trying to get a sub menu going on on the Locations and Menu tabs. I’ll be honest with you and state that I have no idea what I am doing from this point and don’t know where to start. If you can help me I’d much appreciate it.

With that said, I just want the nested list from the Locations and Menu tab to give a sub menu when rolled over. I don’t want to change the style of anything, I like it the way it is. Here’s what I got.

[code=html]
<!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>CSS Rollover Menus</title>
<style type=”text/css”>
#list-menu {
width: 132px;
}
#list-menu ul {
margin: 0;
padding: 0;
list-style-type: none;
font-family: verdana, arial, sanf-serif;
font-size: 12px;
}
#list-menu li {
margin: 2px 0 0;
}
#list-menu a {
display: block;
width:120px;
padding: 2px 2px 2px 10px;
border: 1px solid #000000;
background: #dcdcdc;
text-decoration: none;
}
#list-menu a:link, #list-menu a:active, #list-menu a:visited {
color: #000000;
}
#list-menu a:hover {
border: 1px solid #000000;
background: #333333;
color: #ffffff;
}
</style>
</head>
<body>
<div id=”list-menu”>
<ul>
<li><a href=”/” onfocus=”this.blur()” >Home</a></li>
<li><a href=”/locations/” onfocus=”this.blur()” >Locations</a>
<ul>
<li><a href=”/locations/losangeles.aspx” id=”subNav_losangelesLink” onfocus=”this.blur()”>Los Angeles</a></li>
<li><a href=”/locations/sanantonio.aspx” id=”subNav_sanantonioLink” onfocus=”this.blur()”>San Antonio</a></li>
<li><a href=”/locations/dallasfortworth.aspx” id=”sub_Nav_dallasfortworthLink” onfocus=”this.blur()”>Dallas / Fort Worth</a></li>
</ul>
</li>
<li><a href=”/menu/” onfocus=”this.blur()” >Menu</a>
<ul>
<li><a href=”/menu/coldseafood.aspx” id=”subNav_coldSeafoodLink” onfocus=”this.blur()”>Cold Seafood</a></li>
<li><a href=”/menu/hotseafood.aspx” id=”subNav_hotSeafoodLink” onfocus=”this.blur()”>Hot Seafood</a></li>
<li><a href=”/menu/soups.aspx” id=”subNav_soupsLink” onfocus=”this.blur()”>Soups</a></li>
<li><a href=”/menu/mexicanfood.aspx” id=”subNav_mexicanFoodLink” onfocus=”this.blur()”>Mexican Food</a></li>
<li><a href=”/menu/familymeals.aspx” id=”subNav_familyMealsLink” onfocus=”this.blur()”>Family Meals</a></li>
<li><a href=”/menu/beverages.aspx” id=”subNav_beveragesLink” onfocus=”this.blur()”>Beverages</a></li>
</ul>
</li>
<li><a href=”/aboutus/” onfocus=”this.blur()”>About Us</a></li>
<li><a href=”/contact/” onfocus=”this.blur()”>Contact</a></li>
</ul>
</div>
</body>
</html>
[/code]

Thank you for your time and help.

-Cesar

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@WebJoelApr 04.2007 — Is this a 'drop-down menu'? I think that those require at least some javascript... ? -Maybe there is a all-CSS alternative for a drop-down menu(??).
Copy linkTweet thisAlerts:
@CentauriApr 04.2007 — IF IE supported hover on elements other than <a>, then dropdown menus would be easy. Most css-based dropdowns use javascript to apply behaviours to IE, but this one by Stu Nicholls is all css. Code looks a little messy due to the conditional comments to apply nested tables for the benefit of IE, but it works.

Cheers

Graeme
Copy linkTweet thisAlerts:
@ForeverIriseauthorApr 05.2007 — [code=html]
<!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>CSS Rollover Menus</title>
<style type="text/css">

#list-menu {
width: 106px;
}

#list-menu ul {
margin: 0;
padding: 0;
list-style-type: none;
font-family: verdana, arial, sanf-serif;
font-size: 12px;
}

#list-menu li {
margin: 2px 0 0;
}

#list-menu a {
display: block;
width:90px;
padding: 2px 2px 2px 10px;
border: 1px solid #000000;
background: #dcdcdc;
text-decoration: none;
}

#list-menu a:link, #list-menu a:active, #list-menu a:visited {
color: #000000;
}

#list-menu a:hover {
border: 1px solid #000000;
background: #333333;
color: #ffffff;
}

#list-menu li {
float: left;
position: relative;
width: 10em;
}

#list-menu li ul {
display: none;
position: absolute;
top: 1em;
left: 0;
}

#list-menu li > ul {
top: -2px;
left: 106px;
}

#list-menu li:hover ul, #list-menu li.over ul {
display: block;
}

</style>
<script type="text/javascript"><!--//--><![CDATA[//><!--
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
//--><!]]></script>
</head>
<body>
<div id="list-menu">
<ul id="nav">
<li><a href="/" onfocus="this.blur()" >Home</a></li>
<li><a href="/locations/" onfocus="this.blur()" >Locations</a>
<ul>
<li><a href="/locations/losangeles.aspx" id="subNav_losangelesLink" onfocus="this.blur()">Los Angeles</a></li>
<li><a href="/locations/sanantonio.aspx" id="subNav_sanantonioLink" onfocus="this.blur()">San Antonio</a></li>
</ul>
</li>
<li><a href="/menu/" onfocus="this.blur()" >Menu</a>
<ul>
<li><a href="/menu/coldseafood.aspx" id="subNav_coldSeafoodLink" onfocus="this.blur()">Cold Seafood</a></li>
<li><a href="/menu/hotseafood.aspx" id="subNav_hotSeafoodLink" onfocus="this.blur()">Hot Seafood</a></li>
<li><a href="/menu/soups.aspx" id="subNav_soupsLink" onfocus="this.blur()">Soups</a></li>
<li><a href="/menu/mexicanfood.aspx" id="subNav_mexicanFoodLink" onfocus="this.blur()">Mexican Food</a></li>
<li><a href="/menu/familymeals.aspx" id="subNav_familyMealsLink" onfocus="this.blur()">Family Meals</a></li>
<li><a href="/menu/kidsmeals.aspx" id="subNav_kidsMealsLink" onfocus="this.blur()">Kids Meals</a></li>
<li><a href="/menu/beverages.aspx" id="subNav_beveragesLink" onfocus="this.blur()">Beverages</a></li>
</ul>
</li>
<li><a href="/aboutus/" onfocus="this.blur()">About Us</a></li>
<li><a href="/contact/" onfocus="this.blur()">Contact</a></li>
</ul>
</div>
</body>
</html>

[/code]


I guess a little JavaScripting isn't going to ruin it. This is exactly what I was looking to do. I know now that they are called "Suckerfish Menus". Thanks anyways.

-Cesar
×

Success!

Help @ForeverIrise 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.18,
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,
)...