• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

CSS pseudo classes - turning on without hovering or activating link

 
Ranch Hand
Posts: 236
2
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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




 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put the :hover on the parent.
 
marten koomen
Ranch Hand
Posts: 236
2
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 koomen
Ranch Hand
Posts: 236
2
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


will cause the image CSS to change when the parent is hovered over.
 
marten koomen
Ranch Hand
Posts: 236
2
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could do something like this:



Eric
 
marten koomen
Ranch Hand
Posts: 236
2
jQuery Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, that's neat.
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic