html - 应用选择器的顺序有什么区别
问题描述
任务是为课堂上的所有段落设置红色standart
我是这样做的
.standart p { color:red; }
但有人告诉我这是不好的解决方案,这是“好的解决方案”
p.standart { color:red; }
这两者有什么区别?
解决方案
.standart p { color:red; }
p.standart { color:red; }
<div class="standart">
<p>One</p>
<p>Two</p>
<p>Three</p>
</div>
<hr/>
<p class="standart">One 1</p>
<p class="standart">Two 2</p>
<p class="standart">Three 3</p>
. 标准 p { 颜色:红色;} 表示您想要标准类中所有段落的红色文本。
p.standard {颜色:红色;} 意味着你想要所有具有标准类的段落的红色文本。
推荐阅读
- php - 在 PHP 中为条件循环合并第二个总计数查询
- asp.net-mvc - 使用相同的数据库上下文运行多个选择查询
- unity3d - 进入时播放动画
- python - Bokeh - 在运行时使用小部件来更改图形上显示的数据
- python - 有没有办法在 Odoo 11 中动态地将字段添加到树视图中?
- haskell - Shake:如何在调用时设置环境变量?
- iframe - 带有 iframe 的 Chrome 扩展内容脚本“阻止了具有来源的框架访问跨域框架”
- javascript - 加载 Ajax 页面
- html - Bootstrap 4 - 导航栏折叠时如何连续显示项目?
- javascript - 逐步上传多个文件并列出已上传的文件(NodeJS + Multer)