Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a "last" class on the last <li> within a Views-generated list?

Tags:

css

drupal

How do I add a "last" class on the last <li> within a Views-generated list?

like image 340
user20273 Avatar asked Sep 22 '08 07:09

user20273


People also ask

How do I target the last child of a table in CSS?

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.

Which nth child () selector will target only the last list item?

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.


1 Answers

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.

like image 138
Tim C Avatar answered Oct 31 '22 20:10

Tim C