tags:

views:

1587

answers:

4

I have a draggable div element with a hover style. This works fine, but the div contains some form elements (label, input). The problem is that when the mouse is over these child elements the hover is disabled.

<div class="app_setting">
  <label">Name</label>
  <input type="text" name="name"/>
</div>

.app_setting:hover {
  cursor:move;
}

Any ideas how to get the hover to apply also to the child elements?

+10  A: 
.app_setting *:hover { cursor:move }
garrow
+1  A: 

At least 2 ways of doing it:

  • hover states for each child, either explicitly or with * selector, as suggested by garrow .class *:hover
  • cascade hover state to children .class:hover *

There are probably others

seanb
+1  A: 

You might have to resort to JS to make it happen for IE6.

Jonathan Arkell
I recently decided I won't be supporting IE 6 for any of my new development work.
Toby Hede
Lucky you. :P
Jonathan Arkell
+1  A: 

This isn't a css answer, but it might still be useful to you. Someone else already suggested that you might have to resort to javascript for browser compatibility. If you do resort to javascript, you can use the jquery library to make it easy.

$('.appsetting').hover(hoverInFunc,hoverOutFunc);

This sets an event handler for hovering into and out of the selected element(s) as matched by the css style selector in the $() call.

Mnebuerquo
+1, also consider hoverIntent, it's a plugin that I think is much better than default .hover method.
alex