Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

6 different pics for css Li menu 2

Status
Not open for further replies.

Yogi39

Technical User
Jun 20, 2001
273
CA
I have a 6 item list as a menu.
I would like to use different pictures for eact item in list and then have the picture "dim " on mouseover

Is CSS a good way ? can anyone help with syntax ?
 
Yeah, CSS would be good. You can find numerous examples by searching for "css rollovers" or "css menus" on google. For example, here's a good link:
And this link even uses a list for the menu, which is a good way to do it. This link however has text on each menu button, so you'll need to make some modifications if your text is part of the image. For example, you'd need to set the size of the link to be the size of your image. If you need help on this, get started using the above link and come back with any more questions you have.
 

he following will work in compliant browsers, like Netscape and Mozilla.

However, IE lacks the basic ability to use the HOVER selector on any elements other than A tags :eek:(

Here's the code anyway:

Code:
<HTML>
<HEAD>
<STYLE TYPE=&quot;text/css&quot;>
#listItem1 { list-style-image: url(listitem1image.gif); }
#listItem2 { list-style-image: url(listitem2image.gif); }
#listItem3 { list-style-image: url(listitem3image.gif); }
#listItem4 { list-style-image: url(listitem4image.gif); }
#listItem5 { list-style-image: url(listitem5image.gif); }
#listItem6 { list-style-image: url(listitem6image.gif); }

#listItem1:hover { list-style-image: url(listitem1hoverimage.gif); }
#listItem2:hover { list-style-image: url(listitem2hoverimage.gif); }
#listItem3:hover { list-style-image: url(listitem3hoverimage.gif); }
#listItem4:hover { list-style-image: url(listitem4hoverimage.gif); }
#listItem5:hover { list-style-image: url(listitem5hoverimage.gif); }
#listItem6:hover { list-style-image: url(listitem6hoverimage.gif); }
</STYLE>
</HEAD>
<BODY>

<UL>
	<LI ID=&quot;listItem1&quot;>Item 1</LI>
	<LI ID=&quot;listItem2&quot;>Item 2</LI>
	<LI ID=&quot;listItem3&quot;>Item 3</LI>
	<LI ID=&quot;listItem4&quot;>Item 4</LI>
	<LI ID=&quot;listItem5&quot;>Item 5</LI>
	<LI ID=&quot;listItem6&quot;>Item 6</LI>
</UL>

</BODY>
</HTML>

Hope this helps!

Dan
 

And the following works fine in IE:

Code:
<HTML>
<HEAD>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--

	function mouseOver(element)
	{
		switch (element.id)
		{
			case 'listItem1': element.style.listStyleImage = 'url(listitem1hoverimage.gif)';	break;
			case 'listItem2': element.style.listStyleImage = 'url(listitem2hoverimage.gif)';	break;
			case 'listItem3': element.style.listStyleImage = 'url(listitem3hoverimage.gif)';	break;
			case 'listItem4': element.style.listStyleImage = 'url(listitem4hoverimage.gif)';	break;
			case 'listItem5': element.style.listStyleImage = 'url(listitem5hoverimage.gif)';	break;
			case 'listItem6': element.style.listStyleImage = 'url(listitem6hoverimage.gif)';	break;
		}
	}

	function mouseOut(element)
	{
		switch (element.id)
		{
			case 'listItem1': element.style.listStyleImage = 'url(listitem1image.gif)';	break;
			case 'listItem2': element.style.listStyleImage = 'url(listitem2image.gif)';	break;
			case 'listItem3': element.style.listStyleImage = 'url(listitem3image.gif)';	break;
			case 'listItem4': element.style.listStyleImage = 'url(listitem4image.gif)';	break;
			case 'listItem5': element.style.listStyleImage = 'url(listitem5image.gif)';	break;
			case 'listItem6': element.style.listStyleImage = 'url(listitem6image.gif)';	break;
		}
	}

//-->
</SCRIPT>
<STYLE TYPE=&quot;text/css&quot;>
#listItem1 { list-style-image: url(listitem1image.gif); }
#listItem2 { list-style-image: url(listitem2image.gif); }
#listItem3 { list-style-image: url(listitem3image.gif); }
#listItem4 { list-style-image: url(listitem4image.gif); }
#listItem5 { list-style-image: url(listitem5image.gif); }
#listItem6 { list-style-image: url(listitem6image.gif); }
</STYLE>
</HEAD>
<BODY>

<UL>
	<LI ID=&quot;listItem1&quot; onMouseOver=&quot;mouseOver(this);&quot; onMouseOut=&quot;mouseOut(this);&quot;>Item 1</LI>
	<LI ID=&quot;listItem2&quot; onMouseOver=&quot;mouseOver(this);&quot; onMouseOut=&quot;mouseOut(this);&quot;>Item 2</LI>
	<LI ID=&quot;listItem3&quot; onMouseOver=&quot;mouseOver(this);&quot; onMouseOut=&quot;mouseOut(this);&quot;>Item 3</LI>
	<LI ID=&quot;listItem4&quot; onMouseOver=&quot;mouseOver(this);&quot; onMouseOut=&quot;mouseOut(this);&quot;>Item 4</LI>
	<LI ID=&quot;listItem5&quot; onMouseOver=&quot;mouseOver(this);&quot; onMouseOut=&quot;mouseOut(this);&quot;>Item 5</LI>
	<LI ID=&quot;listItem6&quot; onMouseOver=&quot;mouseOver(this);&quot; onMouseOut=&quot;mouseOut(this);&quot;>Item 6</LI>
</UL>

</BODY>
</HTML>

But for some reason, not so well in NN, Mozilla, or Opera ;o(

Hope this helps anyway!

Dan
 
Thanks!
best I could do ...any sugestions ?
Code:
#navlist {
	position: absolute;
	left: 36px;
	top: 86px;
	width: 186px;
}
#navlist ul {
	margin: 0; /*removes indent IE and Opera*/
	padding: 0; /*removes indent Mozilla and NN7*/
	list-style-type: none; /*turns off display of bullet*/
	font-family: Arial, Helvetica, sans-serif;
	font-size: 14px;
}

#navlist li {
	margin: 0 0 3px 0;
}

#navlist a {
	/*/*/display: block;
	border: 1px solid #333;
	width: 160px;
	background-color: ;
	/* */padding-left:24px; padding-right:2px; padding-top:2px; padding-bottom:2px
}

#navlist a:link, #navlist a:visited {
	color: #000;
	/*/*/color: #EEE;
	text-decoration: none; /* */
}
#navlist a:hover {
	border: 1px solid #333;
	background-color: ;
	color: #333
}

#uberlink a:link, #uberlink a:visited, #uberlink a:hover {
	/*/*/border: 1px solid #333;
	background-color: ;
	color: #333
}

.1{
background-image: url('images/men1.gif')
}
.2{
background-image: url('images/men2.gif')
}
.3{
background-image: url('images/men3.gif')
}
.4{
background-image: url('images/men4.gif')
}
.5{
background-image: url('images/men5.gif')
}
.6{
background-image: url('images/men6.gif')
}

<div id=&quot;navlist&quot; style=&quot;width: 159; height: 150&quot;>
<ul>
<li id=&quot;uberlink&quot;  class= &quot;1&quot;><a href=&quot;#&quot;>Home</a></li>
<li class= &quot;2&quot;><a href=&quot;#&quot;>Page One</a></li>
<li class= &quot;3&quot;><a href=&quot;#&quot;>Page Two</a></li>
<li class= &quot;4&quot;><a href=&quot;#&quot;>Page Three</a></li>
<li class= &quot;5&quot;><a href=&quot;#&quot;>Page Four</a></li>
<li class= &quot;6&quot;><a href=&quot;#&quot;>Page Five</a></li>
</ul></div>


 
Wow thanks for the solutions....dont think I would have ever gotten that far..:)
 
At this point I need to ask myself why on earth do you need a list for this. This is how I would do it (you can easily apply any further rollovers though):
Code:
<style>
<style>
.navlink {
	display: block;
	width: 100px;
	padding-left: 25px; /* as much as you need so it does not overlap the picture */
	text-decoration: none;
	border: 1px dashed #333333;
	margin-top: 2px;
}

a.n1:link, a.n1:visited { background: url('images/men1.gif') no-repeat; }
a.n2:link, a.n2:visited { background: url('images/men2.gif') no-repeat; }
a.n3:link, a.n3:visited { background: url('images/men3.gif') no-repeat; }
a.n4:link, a.n4:visited { background: url('images/men4.gif') no-repeat; }
a.n5:link, a.n5:visited { background: url('images/men5.gif') no-repeat; }
a.n6:link, a.n6:visited { background: url('images/men6.gif') no-repeat; }

a.n1:hover { background: url('images/men1hover.gif') no-repeat; }
a.n2:hover { background: url('images/men2over.gif') no-repeat; }
a.n3:hover { background: url('images/men3over.gif') no-repeat; }
a.n4:hover { background: url('images/men4over.gif') no-repeat; }
a.n5:hover { background: url('images/men5over.gif') no-repeat; }
a.n6:hover { background: url('images/men6over.gif') no-repeat; }

</style>

<a href=&quot;#&quot; class=&quot;navlink n1&quot;>1st choice</a>
<a href=&quot;#&quot; class=&quot;navlink n2&quot;>2nd choice</a>
<a href=&quot;#&quot; class=&quot;navlink n3&quot;>3rd choice</a>
<a href=&quot;#&quot; class=&quot;navlink n4&quot;>4th choice</a>
<a href=&quot;#&quot; class=&quot;navlink n5&quot;>5th choice</a>
<a href=&quot;#&quot; class=&quot;navlink n6&quot;>6th choice</a>
Tested and aced in IE6, Mozilla 1.5 and Opera 7.22. Mozilla gave me some trouble this time and then I noticed you initially had classes named 1,2,3,4,5,6 which is illegal. Changed to n1,n2,n3,n4,n5,n6 and it worked fine. Hope it helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top