CSS Sprites

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
So I've never really done CSS or worked with Sprites (yes yes, *shock* *awe*)... I leave that to brilliant people to do for me and I just do my programming....

Anyway, so now I'm busy doing CSS Sprites. I have a tabbed menu.

The way I've setup the tab is broken up into 3 parts and 3 different tabs (3 different image (png) containing sprites). These will make up 3 states of the tab. Normal, Hover and Active.

The 3 different images contains:

image 1: body (normal/colored for active/colored for active with a little arrow)
image 2: left sides (first in sequence, normal, active side left,active left side last)
image 3: right sides (last in sequence, normal, active right side,active right side last)

All 3 make up one tab:

left - body - right

And depending on the style definition, you get a normal tab/hover tab/active tab

I have seen examples of tabs which uses one image for the entire tab, but this limits the expandability of the tab system by limiting it's width, so I have to cater for differing widths in images rather than what I've used above here (I like using my way, its better :D)

My question is, on hover, I set the background-position to what I want within the sprite to change the state of the button so to speak.... but how to I bring all 3 sprites together in 1 hover?

Currently I can do one of the 3 but not all 3 at the same time making up 1 button.

The positions are correct, and in writing out the html it works perfectly, it's just when I apply the CSS hover (for hover/active for example) is that I can't seem to figure out how to get left body AND right to change

Am I dumb?

Vote now by giving me the answer! :D
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Figured out you can do this:

a:hover {background}
a:hover div.left {background}

etc

cascading... I forgot what that meant ;)
 

FarligOpptreden

Executive Member
Joined
Mar 5, 2007
Messages
5,396
Wow, nobody replied you during those 22 minutes of CSS anguish?! Where was Raithlin during this time? I've got a valid excuse - I had to sit through a 3.5 hour long product demo... :p
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Wow, nobody replied you during those 22 minutes of CSS anguish?! Where was Raithlin during this time? I've got a valid excuse - I had to sit through a 3.5 hour long product demo... :p

hahaha, I actually sat and struggled with it for like 4 hours before I asked. Then it dawned upon me, cascading stylesheets, cascades ;)

I gave up at around 2am when the right corner didn't want to play nice, so I meshed up one button (meaning I have to use several buttons in sprites for differing widths) and it was so much easier...
 
Top