1  添加几个标签

VS Code中html 如何查找标签(5)

<body>
<span>第一个span标签</span>
<p>这是第一个p标签</p>
<span>第二个span</span>
</body>

2  比如查找第二个span标签

VS Code中html 如何查找标签(5)

 

/*1  精确查找, 直接从span的父标签里面查找,查找的就是span,是就直接加载,否则就不加载*/
span:nth-of-type(2){
color: cyan
}
/*2   模糊查找,没找到就不加载,是从所有标签中找*/
span:nth-child(6){
color:green;
}
/*span:nth-child(4){
color: red;
}*/
 
3  具体代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<style>
/*精确查找*/
span:nth-of-type(2){
color: cyan
}
/*模糊查找*/
span:nth-child(6){
color:green;
}
/*span:nth-child(4){
color: red;
}*/
</style>
<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>
</head>
<body>
<span>第一个span标签</span>
<p>这是第一个p标签</p>
<span>第二个span</span>
</body>
</html>
 

相关文章:

  • 2021-06-24
  • 2022-12-23
  • 2021-09-08
  • 2021-07-26
  • 2021-11-05
  • 2022-01-14
  • 2021-11-13
  • 2021-07-23
猜你喜欢
  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
  • 2021-04-17
  • 2021-08-22
  • 2022-12-23
  • 2021-10-03
相关资源
相似解决方案