如何选中相同class类名下最后一项?

发布于 7 年前作者 yeping14754 次浏览最后编辑 7 年前来自 ask

如题 想给同一个class类名下最后一项的border去掉 请问如何实现

1 回复
yandai
yandai1 楼5 年前

你可以试试 .mylast:last-of-type

示例代码:

<style> 
.mylast:last-of-type
{
	background:#ff0000;
}
</style>
<h1>This is a heading</h1>
<div class="mylast">The first paragraph.</div>
<div class="mylast">The second paragraph.</div>
<div class="mylast">The third paragraph.</div>
<div class="mylast">The fourth paragraph.</div>