杰拉斯的博客

归档:2013年11月月

[知乎]关于选择器优先级的计算

杰拉斯 杰拉斯 | 时间:2013-11-25, Mon | 23,789 views
前端开发 

探寻真理者不可心存傲慢”,再一次给自己敲响警钟。

曾经以为

CSS的优先级

不过如此,虽然自己列不出(主要是不喜欢死记理论)所有CSS选择器的优先级顺序,但我在写代码的时候一定能够写对,所以一直看轻了它,直到今天遇到了这样一个问题:

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>CSS Selectors Level</title>
	<style type="text/css">
	.inner:not(#outer) p{color: blue;}
	.outer .inner p{color: orange;}
	</style>
</head>
<body>
	<div class="outer">
		<p>outer</p>
		<div class="inner">
			<p>inner</p>
		</div>
	</div>
</body>
</html>

猜猜是什么颜色?

(阅读全文…)