Search
 
SCRIPT & CODE EXAMPLE
 

CSS

if child elemnt is hovered do changes to the container css

CSS can not select a parent div only when a specific child or descendent element is hovered.  You'll need some JavaScript to achieve what you seem to want.

JavaScript can be added to add something like a "hovered" class to your parent element when various mouse or touch events happen on the child div.  You could edit the CSS properties directly in JavaScript but I would use a CSS class just to keep more of the CSS concerns separate.



The :hover is closely related to your question but it doesn't solve your requirements.  :hover lets you select elements that are hovered over.  If the child is hovered, the parent is also hovered.  There is a problem though.
Here is an example of the problem with :hover:
HTML:
<div class="my-parent">
   <button id="ok">OK</button>
   <button id="cancel">Cancel</button>
</div>

CSS:
.my-parent:hover {
   background-color: green;
}
Say you want the background of my-parent to go red when hovering over "OK".  The above example will do that.  The problem is it'll go green when hovering over the Cancel button too.
Comment

PREVIOUS NEXT
Code Example
Css :: css margin-top 1px 9 
Css :: woocommerce product_cat apply to custom post type 
Css :: revert workflow version servicenow 
Css :: how to create a square element with css with dynamic width 
Css :: target css selector 
Css :: Creating Hashnode logo with CSS 
Css :: Getting strated with boostrap css for html and Reacr framework 
Css :: ancho maximo css 
Css :: CSS - The Descendant Selectors 
Css :: Table Print Cut off right side 
Css :: active css not working 
Css :: parcel-bundler bulma css 
Css :: The HSL color model css 
Css :: long text coming out of the block 
Css :: tailwind css checked 
Css :: csshx iterm2 
Css :: how to open a file in vscode from terminal 
Css :: fade color towards top css 
Css :: bootsrap view only landscape 
Css :: child theme broken header "styles.css" 
Css :: bootstrap pagination left side 
Css :: width height samsung note 20 screen 
Css :: .sidebar { --offset: 2rem; flex-grow: 1; flex-basis: 300px; align-self: start; position: sticky; top: var(--offset); } 
Css :: change size 
Css :: css element with id and class 
Css :: apple gradients 
Typescript :: error: failed to synchronize all databases (unable to lock database) 
Typescript :: matlab run all tests in folder 
Typescript :: if exists drop a temp table 
Typescript :: multi line comments latex 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =