CSS 2,使用链接元素导入的样式表的优先级 [英] CSS 2, precedence of stylesheets imported using link element

查看:113
本文介绍了CSS 2,使用链接元素导入的样式表的优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<link rel="STYLESHEET" href="/css/t.cake.css" type="text/css"/>
<link rel="STYLESHEET" href="/css/f.css" type="text/css"/>
<link rel="STYLESHEET" href="/css/t.generic.css" type="text/css"/>
<link rel="STYLESHEET" href="/css/t.head.css" type="text/css"/>

哪些规则在级联中具有更高的优先级?
假设所有具有相等的优先级wrt其他CSS比较?
第一个或最后一个样式表中的那些?

which rules have a higher priority in the cascade? Assume all have equal priority wrt other CSS comparisons? Those in the first, or last stylesheet?

TIA DaveP

TIA DaveP

推荐答案

根据规范,最新的应用。


4.最后,按指定的顺序排序:如果两个声明具有相同的权重,起源和特异性,后者指定wins。导入样式表中的声明被认为是在样式表本身的任何声明之前。
4. Finally, sort by order specified: if two declarations have the same weight, origin and specificity, the latter specified wins. Declarations in imported style sheets are considered to be before any declarations in the style sheet itself.

无论如何,单独依赖这种方法不是一个好习惯,因为它使得代码难以阅读和解释。我会确保通过选择器的特殊性应用正确的规则,无无论他们放置什么样式表。

Anyhow, would not be good practice to rely on this alone, as it makes your code hard to read and interpret. I would make sure the correct rules were applied through specificity of the selectors, no matter what stylesheet they are placed in.

这篇关于CSS 2,使用链接元素导入的样式表的优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆