aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes CSS pseudo classes - turning on without hovering or activating link Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "CSS pseudo classes - turning on without hovering or activating link" Watch "CSS pseudo classes - turning on without hovering or activating link" New topic
Author

CSS pseudo classes - turning on without hovering or activating link

marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

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






when in doubt put it in parenthesis and stick a dollar sign in front of it, only good can come from this.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61230
    
  66

Put the :hover on the parent.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

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

Joined: Feb 03, 2007
Posts: 178

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

Joined: Jan 10, 2002
Posts: 61230
    
  66



will cause the image CSS to change when the parent is hovered over.
marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178



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

Joined: Nov 08, 2001
Posts: 15376
    
    6
You could do something like this:



Eric
marten kay
Ranch Hand

Joined: Feb 03, 2007
Posts: 178

Thanks, that's neat.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CSS pseudo classes - turning on without hovering or activating link