CSS后代选择器和子代选择器
作者:互联网
知识点1:
默认后代选择器(儿子孙子)
>子代选择器(儿子)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.c1 .c2{
color: red;
}
.c1 p{
color: green;
}
.c1 .c3 .c4{
color: yellow;
}
.c1 .c5{
color: pink;
}
.c1 > .c6{
color: blue;
}
</style>
</head>
<body>
<div class="c1">
<div class="c2">div1</div>
<div class="c2">div11</div>
<div class="c6">div111</div>
<p>p1</p>
<p>p2</p>
<div class="c3">
<div class="c4">div3</div>
<div class="c5">div4</div>
<div class="c6">div111</div>
<p>p3</p>
<p>p4</p>
</div>
</div>
<div class="c1">div2</div>
<div class="c2">div3</div>
</body>
</html>
标签:color,div111,后代,子代,c1,选择器,CSS 来源: https://www.cnblogs.com/A121/p/16295721.html