后代选择器与文字颜色实例页面
展示
1. 颜色是?
2. 颜色是?
代码
-
HTML:
<div class="lightblue"> <div class="darkblue"> <p>1. 颜色是?</p> </div> </div> <div class="darkblue"> <div class="lightblue"> <p>2. 颜色是?</p> </div> </div>
-
CSS:
.lightblue p { color: lightblue; } .darkblue p { color: darkblue; }