How do I add a "last" class on the last <li>
within a Views-generated list?
The :last-child selector is a pseudo-class that allows you to target an element that is the last child element within its parent. See also :first-child, :nth-child, :nth-last_child, and :only-child selectors.
The :nth-last-child(n) selector matches every element that is the nth child, regardless of type, of its parent, counting from the last child.
You could use the last-child pseudo-class on the li element to achieve this
<html>
<head>
<style type="text/css">
ul li:last-child
{
font-weight:bold
}
</style>
</head>
<body>
<ul>
<li>IE</li>
<li>Firefox</li>
<li>Safari</li>
</ul>
</body>
</html>
There is also a first-child pseudo class available.
I am not sure the last-child element works in IE though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With