1. 程式人生 > >CSS繼承多個同樣屬性時的行為

CSS繼承多個同樣屬性時的行為

<span style="font-family: Arial, Helvetica, sans-serif;">p.red {</span>
	color:red;
}
p.green {
	color: green;
}
p.yellow {
	color: yellow;
}

這是樣式及html檔案:

這樣以後


p.red {
	color:red;
}

p.yellow {
	color: yellow;
}

p.green {
	color: green;
}

更改之後:


可以看出和class中的排列順序無關,只和css檔案中的排序有關

<!DOCTYPE html>
<html>
<head>
	<title>Test</title>
	<link rel="stylesheet" type="text/css" href="test.css">
</head>
<body>
	<p class="green red yellow">This is a green text!</p>
	<p class="red yellow green">This is a red text!</p>
	<p class="yellow green red">This is a yellow text!</p>
</body>
</html>