2021/3/16
选择器学习
<!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>选择器权重</title>
<style type="text/css">
a{color: yellow;} /* */
div a{color: green;} /* 1 + 1 */
.demo a{color: black;} /* 10 + 1 */
#demo a{color: orange;} /* 100 +a 1 */
div#demo a{color: red;} /* 1 + 100 + 1 */
</style>
</head>
<body>
<!-- 行内样式<style> 大于 id选择器#box{} 大于 类选择器.nav{} 大于 标签选择器div{} 大于 通用选择器*{}-->
<!-- 权重值依次为1000 100 10 1 0 -->
<a>应该是黄色</a>
<div class="demo">
<a>应该是黑色</a>
</div>
<div id="demo">
<a>应该是红色</a>
</div>
</body>
</html>
效果图