玄鱼殇 2021-01-22 22:33 采纳率: 50%
浏览 47

CSS伪类,nth-last-child问题

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title></title>
	<style type="text/css">
		p:nth-last-child(1){
			color: red;
		}
	</style>
</head>
<body>
	<div class="box">
		<p>p1</p>
		<p>p2</p>
		<p>p3</p>					<!-- 这个确实可以被选中 -->
	</div>
	
	<!-- 为什么这个p没有被选中呢  按道理说是属于body标签的倒数第一个元素,应当被选中-->	
	<p>123</p>		

</body>
</html>
  • 写回答

4条回答 默认 最新

  • 天际的海浪 2021-01-22 23:33
    关注

    你的代码没有啊

    评论

报告相同问题?