Example:
When mouse is over on a LI, the top/bottom border of the LI becomes transparent (replaced by background-color).
But also the bottom-border of the previous LI and the top-border of the next LI must be transparent as well. Can this be done with CSS ?
You cannot select the previous sibling, but you can try some tricks to get the desired effect.
Like this:
demo
Use just
border-top& aninsetbox-shadowon every list item but the fist one in order to mimic the etched top border.Then remove it on
hoverfor the current item and the item that comes right after it.This works in all browsers that support
box-shadow(that is, everything except IE8 and older and less capable mobile browsers).The same effect could be achieved in IE8 by using an absolutely positioned pseudo-element that is given
top: 0; left: 0; height: 1px; width: 100%; background: #fff;(and even in IE7, by adding a child to the list item instead of the pseudo-element). However, I think it’s overkill, especially since the original method degrades gracefully.