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..

    Javascript/Jquery How to catch the use of a CSS class

    gulp-cssmin: How to change relative URLs in minified CSS

    How do I use icons from fontello in my css?

    How to reapply .css file after UpdatePanel asynchronous call completed

    How to reduce space between unordered list and its previous element(center)?

    How to change the included CSS files on button click?

    In CSS, how to select a particular tag under mutiple ids?

    How to draw a circle css

    Codeigniter: how to access css files from different views?

    Div / CSS / ZIndex - how to overlap pictures?

    How can i put random values to css properties using JQuery?

    How to repeat multiple images over one element using CSS

    How to reload a css background-image inside a directive

    How should I add some space between the text and the border using CSS

    With html tables, using CSS, how do I get the tables next to each other?

    How do I integrate a jQuery script in to my html file?

    How to place the text after thumbnails at the bottom?

    How to add space between CSS table rows?

    How to get this div into the right position

    Change Color Themes - How To Prevent the Site Goes Back to Default

    How does a document reference an SCSS file?

    How to align the header menu from left? i see a unexpected margin on left. Help please

    How to change a portion of text on hover with css [duplicate]

    How can I get css pseudo element :checked to work in IE7 + IE8?

    CSS how to round of percent values to whole number pixel

    How to CSS for today's Internet? [closed]

    How to change css image via php depending on weekday

    How to wrap text in table cell without wrapping child elements

    how to properly override CSS in external file

    How would you code this: The SO highlighted button outline effect [closed]