Mia
Mia

Reputation: 6531

DIV:hover changes attributes of another DIV

I'm trying to change the attributes of one div from another div's hovering. Both of the div's has their own unique ID and I'm wondering if this is possible.

Here is the jsfiddle link: http://jsfiddle.net/Ngx5D/

And here is the sample code:

body {
    background-color:lightgrey;
}

#div_one, #div_two{
    background-color:darkred;
    display:block;
    width:300px;
    text-align:center;
    padding:30px;
    margin:10px;
    color:white;
    -webkit-transition: 0.3s ease;
    -moz-transition: 0.3s ease;
    -ms-transition: 0.3s ease;
    -o-transition: 0.3s ease;
    transition: 0.3s ease;  
}

#div_one:hover {
    background-color:red;
}

Upvotes: 0

Views: 87

Answers (1)

sandeep
sandeep

Reputation: 92863

Write like this:

#div_one:hover + #div_two{
    background-color:red;
}

Check this http://jsfiddle.net/Ngx5D/1/

Upvotes: 4

Related Questions