<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS权重的叠加</title>
<style>
/* 复合选择器会有权重叠加的问题 */
/* 权重虽然会叠加,但是永远不会有进位 */
/* ul li 权重 0,0,0,1 + 0,0,0,1 = 0,0,0,2 2*/
ul li {
color: blue;
}
/* li权重 0,0,0,1 1*/
li {
color: green;
}
/* .nav li 权重 0,0,1,0 + 0,0,0,1 = 0,0,1,1 11*/
.test li {
color: pink;
}
</style>
</head>
<body>
<ul class="test">
<li>大猪蹄子</li>
<li>大肘子</li>
<li>猪尾巴</li>
</ul>
</body>
</html>
01-08
351
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)