CSS3 :last-of-type 选择器 | CSS 伪类(Pseudo-classes) | CSS教程

返回到:CSS 伪类(Pseudo-classes) | CSS教程

定义和用法

:last-of-type选择器匹配元素其父级是特定类型的最后一个子元素。

提示: 和:nth-last-of-type(1)是一个意思。

浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号。

选择器谷歌IE火狐苹果opera
:last-of-type4.09.03.53.29.6

实例

指定其父级的最后一个p元素的背景色:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Web176教程(web176.com)</title> 
<style> 
p:last-of-type
{
	background:#ff0000;
}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>

</body>
</html>

作者:terry,如若转载,请注明出处:https://www.web176.com/cssprop/5364.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2022年4月7日 上午11:50
下一篇 2022年4月7日 上午11:58

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注