css 的优先级秩序是什么?
<div style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">按照</span>下面的代码进行验证,先去掉!important,验证三种样式表的优先级,<span style="color: black;">而后</span>再加上!important,验证!important的优先级。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><!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>Document</title>
<!-- <span style="color: black;">外边</span>样式表 -->
<link rel="stylesheet" href="css/waibu.css">
<!--<span style="color: black;"><a style="color: black;">内部样式表</a></span>-->
<style>
div{
width:300px !important;
height:300px !important;
bac<span style="color: black;">公斤</span>round-color: green !important;
}
</style>
</head>
<body>
<!-- 行内样式表 -->
<!-- style="width:100px;height:100px;bac<span style="color: black;">公斤</span>round-color:red" -->
<div ></div>
</body>
</html></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">最后</span>结论:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">选取</span>器权重: !important(10000)>行内(1000)>id(100)>类(10)>标签(1)><span style="color: black;"><a style="color: black;">通配符</a></span>(0)</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">仔细</span>内容查看以下<span style="color: black;">文案</span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><a style="color: black;"><span style="color: black;"><span style="color: black;">diveng:<span style="color: black;">怎样</span>理解CSS样式表权重与</span></span></a>优先级<span style="color: black;">1 赞同 · 0 评论<span style="color: black;"><span style="color: black;">文案</span></span></span><span style="color: black;"><img src="https://pic2.zhimg.com/v2-810eadf61cc361f06d2fb335feccdbfd_180x120.jpg" style="width: 50%; margin-bottom: 20px;"></span></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>你想学习高级<span style="color: black;">选取</span>器的<span style="color: black;">运用</span>,<span style="color: black;">例如</span>子代<span style="color: black;">选取</span>器,<span style="color: black;"><a style="color: black;">后代<span style="color: black;">选取</span>器</a></span>,相邻兄弟<span style="color: black;">选取</span>器,<span style="color: black;"><a style="color: black;">群组</a></span><span style="color: black;">选取</span>器等等,请查看,</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">海量</span>案例,清晰易懂,CSS优先级,<span style="color: black;">选取</span>器权重,看上面2篇<span style="color: black;">文案</span>就足够了。</p>
</span></div>
期待你更多的精彩评论,一起交流学习。 你的见解独到,让我受益匪浅,期待更多交流。
页:
[1]