级选择器分为:后代选择器、子代选择器、并集选择器、交集选择器
 
后代选择器
使用空格表示后代选择器。顾名思义,父元素的后代(包括儿子,孙子,重孙子)
.container p{
    color: red;        
}
.container .item p{
    color: yellow;
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <style type="text/css" media="screen">
    #box p{
        color: red;
    }

    </style>

</head>

<body>
<div id="box" class="wrap">
    <div id="box2" class="wrap2">
        <div id="bo3" class="wrap3">
            <p>猜猜我是什么颜色</p>
        </div>
    </div>

</div>

</body>
</html>
例子

相关文章:

  • 2021-08-28
  • 2021-10-07
  • 2022-01-04
  • 2022-01-28
  • 2022-12-23
  • 2021-04-06
  • 2022-12-23
猜你喜欢
  • 2022-02-21
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2022-03-05
  • 2021-05-23
  • 2021-09-24
相关资源
相似解决方案