if you does not recieve answers that help from backend perspective, I am sure that you can solve this from jquery perspective:
Jquery select first and last divs from a list of items: https://stackoverflow.com/questions/3328076/jquery-select-first-and-last-divs-from-a-list-of-items
For instance this set of divs (also is possible with li
, a
, etc..):
<div class="item">qwe</div>
<div class="item">asd</div>
<div class="item">zxc</div>
<div class="item">ghj</div>
<div class="item">bnm</div>
with Jquery you can select first and last item, in this case, to add a class to first/last target elements (put this in the end of your view results template):
<script>
$('.item')
.eq(0).addClass('first').end()
.eq(-1).addClass('last').end();
</script>
of course you must have respective class to this different elements, for instance:
<style type="text/css">
.first, .last{
background-color:#0099FF;
}
</style>
and here is the result:

this is another example: Addressing first/last item in an ul, li: https://stackoverflow.com/questions/5680032/addressing-first-last-item-in-an-ul-li
I hope information be useful.