how to change properties of a parent div on hover of child div


Tags: html,css

Problem :

how to change properties of a parent div on hover of child div. can it be done with pure css ?

html:

<div class="parent">
    <div class="child">
    </div>
</div>

css:

.parent{width:200px;height:100px;background:#cccccc;}
.child{width:200px;height:100px;background:transparent;}


Solution :

Is there a reason you do not want to use JavaScript or JQuery?

You could simply:

$("#child_id").hover(function (){
  $(this).parent("div").addClass("some-class")
});

    CSS Howto..

    How to correctly override inaccessible HTML content with CSS?

    How to make the contents of an HTML table fit within their cells?

    How to prevent one table from obeying CSS rule

    How to display form labels with more than one element per line? jsfiddle

    How to align multiple images horizontally (in a row)?

    How to create a box when mouse over text in pure CSS?

    How to refer to an id with special characters in CSS

    HTML/CSS: How to get the id of sub menu

    How to format an arabic poem using jquery?

    How to position a background image like wanderfly.com?

    How to extract icon from picture and display it in page? (by javascript or jquery or css)

    how can I set my gradient background in css for full width and height of the page?

    How to break CSS inheritance?

    How to get a working CSS zigzag border?

    How to center align a div vertically which uses bootstrap?

    How to change all CSS file into SCSS

    Bootstrap table table-condensed table-hover, Top Border not showing

    How to Layout a Watermark Image that is transparent along with a banner image and content div?

    How to display first tab by default in css?

    How to change iframe pages without the parent page changing with external links using CSS

    How can I target text input fields with CSS?

    How to program a CSS3/JQuery/Flexslider carousel with visible sides

    Bootstrap tooltip showing behind modal window

    How to edit the CSS of a div that does not contain a H1 tag?

    IcoMoon App icon fonts are shown as 

    How should you comment css? [closed]

    How can I hide elements on a HTML page until a user hovers over it using CSS?

    How to dynamically change CSS style attribute of DIV tag?

    How to make fadeIn() and hide() work only for tablet and desktop versions?

    Popup not showing once per session as wanted (as mentioned by client)