Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

targeting li on hover but not parent li

I have a dynamically generated list that has potentially up to about 5 levels. I want the listed item text to underline when I hover over the listed item, however not the parent li.

see example.

http://jsfiddle.net/ca7fL/5/

you see when you hover on "this", the above parent li, underlines aswell.

Any ideas?

Cheers

like image 848
AJFMEDIA Avatar asked Aug 25 '11 08:08

AJFMEDIA


People also ask

Does hover only work on links?

Definition and Usage The :hover selector is used to select elements when you mouse over them. Tip: The :hover selector can be used on all elements, not only on links.

Why Hover is not working on div?

You might have linked your stylesheet to your HTML file improperly. Some other CSS in the context of your project may be overriding the piece that you've given here. You might be running into browser compatibility issues with the :hover selector or something else in your code that is breaking the styling.

What is&: hover CSS?

The :hover CSS pseudo-class matches when the user interacts with an element with a pointing device, but does not necessarily activate it. It is generally triggered when the user hovers over an element with the cursor (mouse pointer).


1 Answers

That seems hard to achieve, since when you point the child li element you're also effectively pointing its parent.

There is a solution, though: add a span tag to your menu items, and make that tag hoverable: http://jsfiddle.net/ca7fL/16/

like image 170
Clément Avatar answered Nov 04 '22 18:11

Clément