0

I have 3 divs

in this order 1 - 2 - 3

I want to change the background of 1 & 3 when I hover over 2 (using css)

so far only div 3 will change

Ward
  • 1
  • 1
  • 1
    CSS has no previous-element selector, this can be approximated with CSS, but not perfectly. The best solution, for this problem, is to use JavaScript. – David Thomas May 18 '13 at 19:41
  • 1
    Without seeing your code, it's difficult to make any sort of guesses as to what your problem is. – Blender May 18 '13 at 19:42
  • A possible duplicate of [Change color of sibling elements on hover using CSS](http://stackoverflow.com/questions/12574668/change-color-of-sibling-elements-on-hover-using-css) – David Thomas May 18 '13 at 19:42

1 Answers1

1

Use the classes to style them on hover in your CSS. Example:

<div class="one"> First </div>
<div class="two"> Second </div>
<div class="three"> Third </div>



.one:hover, .three:hover {
 background: pink; 
 }
Qristhal
  • 41
  • 5