CSS类名选择器顺序和层级的权重实例页面
回到相关文章 »代码:
CSS代码:
.red { color: red; } .green { color: green; }
HTML代码:
<div class="red"><div class="green"><p>1. 颜色是?</p></div></div> <div class="green"><div class="red"><p>2. 颜色是?</p></div></div>
效果:
1. 颜色是?
2. 颜色是?
.red { color: red; } .green { color: green; }
<div class="red"><div class="green"><p>1. 颜色是?</p></div></div> <div class="green"><div class="red"><p>2. 颜色是?</p></div></div>
1. 颜色是?
2. 颜色是?