Fixed bug with invalid selection of previous item in CSS