Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jeremy Cornwell
11,106 PointsHover over one div effects another div inside a separate container, possible?
If I hover over an element in a container is it possible to modify an element into a completely different container.
<div class="container1">
<effect this item>
</div>
<div class="container2">
<div1></div>
<hover over this div></div>
</div>
3 Answers
anil rahman
7,786 Pointsyes it is possible :)
You would use syntax like this
#container2:hover ~ #container1 {
//change stuff here
}
Jeremy Cornwell
11,106 PointsIsn't that a sibling selector? The two elements aren't siblings since they're located in separate containers. I could be wrong on how that works.
Niilo Smeds
12,540 PointsIt should be possible, but the div to be modified must come after the div you are hovering over in your html document. The selector you use will depend on how your html is arranged. See my answer to a similar question and the W3 page on CSS combinators.