示例 2 : style标签上的与style属性冲突 示例 3 : !important <link rel="stylesheet" type="text/css" href="https://how2j.cn/study/style.css" />
<style>
.p1{
color:green;
}
</style>
<p class="p1">p1 颜色是绿色,优先使用靠的最后出现的</p>
<link rel="stylesheet" type="text/css" href="https://how2j.cn/study/style.css" /> <style> .p1{ color:green; } </style> <p class="p1">p1 颜色是绿色,优先使用靠的最后出现的</p>
如果样式上增加了!important,则优先级最高,甚至高于style属性
<style>
.p1{
color:green !important;
}
</style>
<p class="p1" style="color:red">p1 颜色是绿色,优先使用!important样式</p>
<style> .p1{ color:green !important; } </style> <p class="p1" style="color:red">p1 颜色是绿色,优先使用!important样式</p>
HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
|