I have always the same problem, when I have 2 adjacent elements with borders, the borders are merged. With tables we have the border-collapse property for solving this.
I've tried omiting the border from one of the sides, but that works only for elements in the middle, the first and final element will miss a border.
Does somebody know a solution for list elements for example?
Little late to this party, but here's how to get a list item's complete border to change on hover.
First, just use (top and side) borders on the
li
elements, then give the last one a bottom border.Then, choose a hover border style:
Finally, use a sibling selector to change the next item's top border to match your hover item's hover border.
http://jsfiddle.net/8umrq46g/
You can do this using CSS pseudo selectors:
This will clear the right hand border on all li elements except the last one in the list.
You can add a left and bottom border to the ul and drop it from the li.
fiddle: http://jsfiddle.net/TELK7/
html:
css:
Old thread, but I found another solution, and more important:
YOU DON'T HAVE TO KNOW WHICH IS THE PARENT ELEMENT
This thread is pretty old, but I found a new solution using the outline property. It works for vertical and horizontal lists, even if the horizontal list is multiple lines long.
Use a border of half the intended width, and add an outline also of half the intended width.
Here's how I solved it: add a margin-left/-top of -1px to each li element. Then the borders really collapse without any tricks.