Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CSS pseudo classes - turning on without hovering or activating link

 
marten kay
Ranch Hand
Posts: 178
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am look to develop span pairs - one containing text and another an image - as control/button/links on a web page; giving users both a text and graphic cue. I wish to synchronize the pseudo class for both elements in the pair, that is, should the mouse hover over the text span, the image hover pseudo class should turn on as well.

I there a way to achieve this? my example is below, pretty stock standard.

Marten




 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the :hover on the parent.
 
marten kay
Ranch Hand
Posts: 178
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I should have thought of that.

but that would work for the text, but not necessarily for the image background in the second span... I will play around
 
marten kay
Ranch Hand
Posts: 178
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm able to get the text to change when the mouse hovers/actives the image by putting the pseudo class on the parent (see below) but I can't do that for the image.





I also tried to dispatch the event to the childNodes, but that didn't work either, I suppose a 'hover' is not the same as 'mouseover'. So this is not working



Having the text change when the user hovers or activates the image is OK, but sub optimal. Any further ideas appreciated.

Thanks

Marten>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


will cause the image CSS to change when the parent is hovered over.
 
marten kay
Ranch Hand
Posts: 178
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


thanks!

Got it, not quite as suggested because I couldn't figure out how to use the img tag for this, but my solution is below.... now I will generalize for a servlet response.

... never found selectors very interesting until now!

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could do something like this:



Eric
 
marten kay
Ranch Hand
Posts: 178
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that's neat.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic