i saw a sharepoint where its list item as a background color (blue) for odd list item number and another (white) for even numbers. I dont know where i can set this.

I looked into designer and i could do it with the ID property and check if the list item is even or odd and then change the background color but the problem is if i do this and they change the way the list is ordered then it will be all messed up. Help anyone ?



If you are talking about XSLTListViewWebPart then there should be a class ms-alternating for every second <tr> which you can use to select in CSS, like this:

.ms-itmhover { background-color: darkblue }
.ms-alternating { background-color: darkred }

Another fun way is to use pseudoselects like :not(.ms-alternating) or more fun:

tr:nth-child(odd) { background-color: darkblue }
tr:nth-child(even) { background-color: darkred }

But be aware about browser support.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.