0

The goal

Change an element by hovering another with CSS.

The problem

I don't know the syntax. Any ideas?

Code spotlight

I want to change .frame by hovering .app > a. The CSS syntax is spotlighted below:

.app a:hover ->¹ .frame {
    background-color: yellow;
}

.frame {
    background-color: blue;
    width: 300px;
    height: 300px;
}

¹ just illustration.

(Also available in jsFiddle)

Guilherme Oderdenge
  • 4,935
  • 6
  • 61
  • 96

1 Answers1

3

Try this on for size:

.app:hover ~ .frame {
    background-color: yellow;
}

.frame {
    background-color: blue;
    width: 300px;
    height: 300px;
}

Demo: http://jsfiddle.net/maniator/jWA3s/1/


Reference: What does the "~" (tilde/squiggle/twiddle) CSS selector mean?

Community
  • 1
  • 1
Naftali
  • 144,921
  • 39
  • 244
  • 303