0

我想知道是否有人可以告诉我为什么列表没有设置为斜体作为 div 中的一个类?

<style type="text/css">
body{
font:62.5% Arial, Helvetica, sans-serif;
}
h1{
font:small-caps 1.6em "Times New Roman", Times, serif;
}
.recipe .intro{
font:italic 1em Arial, Helvetica, sans-serif;
}
</style>
</head>

<body>
<h1>Recipes for Cheese</h1>

<p class="intro">Cheese is a remarkably versatile food, available in literally hundreds of         varieties with different flavors and textures.</p>

<div class="recipe">

<h2>Welsh Rarebit</h2>

<p class="intro">Cheese is a remarkably versatile food, availalbe in literally hundreds of varieties with different flavors and textures.</p>

<ol>
<li>Lightly toast the bread</li>
<li>Place on a baking tray, and spread with butter.</li>
<li>Add the grated Cheddar cheese and 2 tablespoons of beer to a saucepan. Place the saucepan over a medium heat, and stir the cheese continuously until it has melted. Add a teaspoon of wholegrain mustard and grind in a little pepper. Keep stirring.</li>
<li>When thick and smooth, pour over each piece of taost spreading it to the edges to stop the toast from burning.</li>
<li>Place under the grill for a couple of minutes or until golden brown.</li>
</ol>
</div>    
</body>

订单列表不应该是斜体,因为它在类食谱中。请解释为什么不是。

谢谢

4

2 回答 2

2

<li>不继承 css 类的属性.recipe,为了应用它,您必须执行以下操作:

.recipe li{
    font:italic 1em Arial, Helvetica, sans-serif;
}

标签也是如此<a>,您必须在.css

您可以查看此演示

如果您想获取更多信息,请查看此文档

于 2012-06-06T01:41:52.093 回答
1

只有.recipe .intro(您的段落标签)已font:italic 1em Arial, Helvetica, sans-serif;应用。要让所有人都.recipe拥有该字体,请删除.intro.

.recipe .intro说:“对于所有具有intro类的所有元素都是具有该类的所有元素的后代recipe,应用这些样式。”

于 2012-06-06T00:11:08.463 回答