Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS for hover that includes all child elements

Tags:

html

css

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?

like image 954
Toby Hede Avatar asked Sep 26 '08 02:09

Toby Hede


People also ask

How do you add hover effect on child element?

Add :hover to the <div> tag and specify the background property. Set :hover and padding-bottom to the <p> element inside the <div> tag. Also, specify the background. Set the position to “absolute” and specify the bottom for the <button> element inside the <div> tag.

How do I get a div for all my children?

If You want to get list only children elements with id or class, avoiding elements without id/class, You can use document. getElementById('container'). querySelectorAll('[id],[class]'); ... querySelectorAll('[id],[class]') will "grab" only elements with id and/or class.

How do you select all child elements except last?

When designing and developing web applications, sometimes we need to select all the child elements of an element except the last element. To select all the children of an element except the last child, use :not and :last-child pseudo classes.


2 Answers

.app_setting *:hover { cursor:move } 
like image 193
garrow Avatar answered Sep 21 '22 20:09

garrow


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

like image 30
seanb Avatar answered Sep 19 '22 20:09

seanb