tags:

views:

36

answers:

1

here is some "normal" code for sprite menu

#menu li a
{
    background:url('../layout/menu.jpg') no-repeat;
    display:block;
    text-decoration: none;
    width:100%; height:100%; 
}

#menu li.m1 a{ background-position:0px 0px; }
#menu li.m1 a:hover{ background-position:0px -55px; }
#menu li.m1 a.selected{ background-position:0px -55px; }

I have 6 different item, that will require 6 different class x 3 for hover

It'a can be done EASILY with jquery in 2-3 lines, but having to load a library for something simple as that... not sur it worth it...

So, YOU will go with the jquery method, or just copy paste as many css rule as need....

Just making thing over and over again, make me thing there is a better way !

+1  A: 

Use CSS and use a class instead of an ID. Then you don't need to duplicate:

.menu li a
{
    background:url('../layout/menu.jpg') no-repeat;
    display:block;
    text-decoration: none;
    width:100%; height:100%; 
}

.menu li.m1 a{ background-position:0px 0px; }
.menu li.m1 a:hover{ background-position:0px -55px; }
.menu li.m1 a.selected{ background-position:0px -55px; }
GenericTypeTea