0

What i want to do is when i hover the '#two' the hover changes apply on the '#one' i did it on vice-versa but i have no clue for the opposite. I have this code:

<html>
<head>
<style>
    #one{
        background-color: red;
        width: 200px;
        height: 200px;
    }
    #two {
        background-color: #000;
        width: 200px;
        height:200px;
    }
    #one:hover + #two {
        background-color: blue;
    }
    #two:hover #one {

    }
</style>
    </head>
    <body>
<div id="one"></div>
<div id ="two"></div>
    </body>
    </html>
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Miguel
  • 1,579
  • 5
  • 18
  • 31
  • 1
    There is no "previous sibling" CSS selector. – j08691 Apr 14 '14 at 17:00
  • generally speaking, you can just select ***downwards*** only in current CSS standard. In future we may refer to the parent of the element and it will be so powerful. – King King Apr 14 '14 at 17:03
  • j08691 is correct. Check out this post which has more info on this http://stackoverflow.com/questions/1817792/css-previous-sibling-selector – Abhi Apr 14 '14 at 17:11
  • In CSS Selectors 4 you will be able to set the [subject of a selector](http://www.w3.org/TR/2013/WD-selectors4-20130502/#subject): `!#one + #two:hover`. But it will be slow, it's a feature of the complete profile instead of the fast one. – Oriol Apr 14 '14 at 17:12
  • @Oriol: That reminds me - I recall seeing a proposal for delayed/deferred selector matching that could work with slow selectors and selectors that don't need to match instantly. It's just an idea for now, but who knows, maybe someone can come up with something. For now though the complete selector profile is simply being excluded from CSS altogether so it won't just be slow, it simply won't work. – BoltClock Apr 14 '14 at 17:18

0 Answers0