I have an unordered list, which can contain either an even or odd number of items. I'm looking for a CSS-only way to remove the border from the last 2 li
tags if the number of li
s is even. The :last-child
pseudo-selector removes the last one regardless.
li {
float: left;
border-bottom: 1px solid #000;
}
li:last-child{
border-bottom: none;
}
Works for Odd Numbers of li
s
+============================================+
+ 1 | 2 +
+--------------------------------------------+
+ 3 | +
+============================================+
But for even numbers, I need to remove the bottom of cell #3
+============================================+
+ 1 | 2 +
+--------------------------------------------+
+ 3 | 4 +
+--------------------- +
+============================================+
So I figured I could use li:nth-last-child()
but I can't figure out what should be the equation to grab the last odd child.
It's not 2n+1
, 2n-1
, n-1
, or anything I can think of. Please help.