html - 选择第二个匹配的类项,而不是 CSS 中的元素
问题描述
这仅在 CSS 中可行吗?我无权访问 HTML 或 JS。我需要选择第二个匹配选择器,而不是元素。
这在页面中重复了两次,但我找不到只更改第二个元素的样式的方法。
.testimonials .testimonials-content .cover-component-slide{
/* Change the second one */
}
解决方案
.msg:nth-of-type(2) {
color: red;
}
<h1 class="msg">Hello World One</h1>
<h1 class="msg">Hello World Two</h1>
推荐阅读
- selenium - Selenium 发送键间歇性地跳过文本字段
- node.js - 使用 VSCode 远程容器下载 vscode-server 时无法建立 TLS 连接
- amazon-web-services - 在 AWS 中创建 IAM 策略以保护根用户的 EC2 实例
- javascript - 如何获取 Windows 命令结果并在 chrome 浏览器中显示警报
- laravel - Laravel 验证:如果另一个字段可用,则需要两个字段中的任何一个
- javascript - 如何从 HTML 表单中收集所有值?
- angular - 未处理的承诺拒绝:this._next 不是函数:@angular/fire/messaging 中的区域
- python - python对象的自定义过滤功能
- html - 为什么弹性容器内的弹性项目需要最小宽度来封装弹性项目
- ruby-on-rails - 当用户已经通过身份验证时,在设计中运行守望者策略