Another option would be to apply a class to the visible elements when hiding the others. Apply nth-child to this class (which is only applied to the visible elements.)
You don't have to use an !important tag to keep your hover-background in this case.