在这段代码中,我的段落看起来像这样
<p class="special">
This is just a test. <em>what color here</em> inheritance work
</p>
我想知道为什么字符串“这里的颜色”不是从父p
元素中获取颜色。我的意思是特殊类的特异性值为 10,而诸如 em 之类的类型的特异性值为 1,所以这里 10 大于 1。
所以我的意思是颜色应该取自选择器.special
这是标记和CSS
<!DOCTYPE html>
<html>
<head>
<meta name="keyword" content="html5. tutorial" charset=utf-8" />
<title></title>
<style type="text/css" media="screen">
em
{
font-weight:bold;
color:red;
}
.special
{
color:blue;
}
</style>
</head>
<body>
<p class="special">
This is just a test. Is this color <em>red</em> inheriatance work
</p>
</body>
</html>
//托尼