html - 全新的 CSS,无法弄清楚如何为我的每个 html 段落正确编码不同的类/属性值
问题描述
我目前正在学习如何使用类选择器,并且知道一旦我为我的 html 中的特定段落分配了一个类,我的下一步应该是在我的 CSS 中为这些类创建新规则。我正在关注 Head First HTML CSS 指南,他们没有为此指定明确的路径。任务是为每个段落分配不同的颜色。虽然第一个 (p class="greentea")只有一个段落显示了所需的颜色,但 p.greentea {color: green;} 确实有效,其余的则没有。有人可以校对代码并让我知道我做错了什么吗?谢谢你。
HTML
p.greentea {
color: green;
}
p.raspberry {
color: blue;
}
p.blueberry {
color: purple;
}
p.cranberry {
color: red;
}
<p class="greentea">
<img src="../images/green.jpg">
Chock full of vitamins and minerals, this elixir
combines the healthful benefits of green tea with
a twist of chamomile blossoms and ginger root.
</p>
<h2>Raspberry Ice Concentration</h2>
<p class="raspberry">
<img src="../images/lightblue.jpg">
Combining raspberry juice with lemon grass,
citrus peel and rosehips, this icy drink
will make your mind feel clear and crisp.
</p>
<h2>Blueberry Bliss Elixir</h2>
<p class="blueberry">
<img src="../images/blue.jpg">
Blueberries and cherry essence mixed into a base
of elderflower herb tea will put you in a relaxed
state of bliss in no time.
</p>
<h2>Cranberry Antioxidant Blast</h2>
<p class="cranberry">
<img src="../images/red.jpg">
Wake up to the flavors of cranberry and hibiscus
in this vitamin C rich elixir.
</p>
解决方案
推荐阅读
- sql - 如何在没有变量的情况下将 XML 单元格解析为多条记录?
- python-3.x - 可以在一行中完成三个迭代吗?Python 3 for 循环
- python - 如何通过 openpyxl 将整个工作表导入列表
- linux - 我的 Nvidia 驱动程序不用于 OpenGL 渲染?
- typescript - 为什么我的 Jest Function Mock 会影响另一个测试
- c++ - C++,sqlite3. BLOB字段作为查询条件如何处理?
- php - 贝宝订阅:结账时未显示费用?
- visual-studio - Visual Studio C++ 程序集 | 括号的含义?
- .net - 如何在多个服务器中使用相同的域(www.example.com)?
- shell - 使用电子邮件 ID 向用户发送通知的 Shell 脚本从数据库中获取它