Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 ?

Thanks

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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