Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [How]When hovering on a child div the main div changes color.

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #43634
    apart
    Participant

    So i want to make when you hover over the #prvi div the #main changes it’s background color.

    I tried something like this:

    #prvi:hover #main{
    background-color:#d5F986;
    }

    But that doesn’t work. Here is the[ codepen](http://codepen.io/markomarkogame/pen/DyIvo “codepen”).

    #129571
    CrocoDillon
    Participant

    What you need is a parent selector, which doesn’t exist yet. You can do it with jQuery though.

    #129572
    apart
    Participant

    So it was done in jQuery [here](http://www.codeschool.com/ “here”) ? (the Paths sections)

    Since I’m no good in jQuery i might as well give up on this ..

    #129603
    CrocoDillon
    Participant

    Yes, on that site they use JS (didn’t check if it is jQuery, but probably it is) to add classes like `path-ruby` to the container.

    Here is how it can be done using jQuery: http://codepen.io/CrocoDillon/pen/tqEfh


    @Krish1980
    , you’re removing all other classes from the parent div like `.parent`. That’s why I like jQuery so much, functions like `addClass` and `removeClass` automatically keep the other classes :)

    #129626
    apart
    Participant

    Wow cool stuff guys.


    @CrocoDillon
    nice fade in and out I was wondering where could i learn to do something like this, looks simple.

    #129671
    apart
    Participant

    Anyone ? Any link to point me how to do this kind of stuff, nothing complicated ?

    #129680
    CrocoDillon
    Participant

    Start by learning [JavaScript](https://developer.mozilla.org/en-US/docs/JavaScript/Guide), then move on to (or skip to if you don’t feel like reading all that) [jQuery](http://try.jquery.com/). I haven’t really tried the last link yet but it seems rather easy with videos and exercises.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘CSS’ is closed to new topics and replies.