首页 > 解决方案 > 在另一个类中使用一个类

问题描述

我有以下代码:

.description p span {
  font-style: italic;
}
<div class="description">
  <p>This recipe is from one of my <span class="cor">favorite</span> cakes out there, really <span>delicious</span>...check it out below</p>
</div>

但我希望第一个跨度标记中的类将所有斜体文本删除为红色

标签: htmlcss

解决方案


使用您为跨度本身提供的类。

.description p span {
  font-style: italic;
}

.description .cor {
  font-style: normal;
  color: red;
} 
<div class="description">
  <p>This recipe is from one of my <span class="cor">favorite</span> cakes out there, really <span>delicious</span>...check it out below</p>
</div>


推荐阅读