<h1>This is a heading.</h1> <p>This is paragraph.</p> <p>This is paragraph.</p> <style type="text/css"> h1 + p {margin-top:50px;} </style>复制代码 相邻兄弟选择器用 + 号连接 父级元素指向子集元素用>复制代码 <style> .father{ color: yellow; } .father:hover>.son{ color: red; } .father:hover+.fatherB{ color: blue; } .father:hover+.fatherB>.sonB{ color: green; } </style> <body> <div class="father">father <div class="son">son</div> </div> <div class="fatherB">父亲 <div class="sonB">儿子</div> </div> </body>复制代码 转载于:https://juejin.im/post/5c7de432e51d4502560f515c