The only way of doing that with CSS only is using an extra div to cover maindiv when the hover happens. And it would not work on IE < v9, since it would need z-index
This would be the markup
<div id="MainDiv">
<div id="nesteddiv1"></div>
<div id="nesteddiv2">
<div id="extradiv"><div>
</div>
</div>
The CSS would be very tricky.
(disclaimer: this hasn't been tested - probably you would need more rules)
- MainDiv would have to be position:relative or position:absolute, fixed width and height, and z-index = -1.
- Nested divs 1 and 2 can NOT be position:relative or absolute, and z-index = 1
- Extra div would have to be: position:absolute, top:0, left:0, and same witdth and height as MainDiv, display:hidden, and z-index = 0
- #nexteddiv2:hover #extradiv would have display:block
z-index would make maindiv stay allways behind the others, while nested divs 1 and 2 always stay on top. extradiv would be between them, 'covering' maindiv, but only when nesteddiv2 is hovered.
A drawback of this method would be that extradiv would be visible until you stopped hovering it, not just nesteddiv2.