选择第二个匹配的类项目,而不是CSS中的元素

时间:2019-02-20 12:24:49

标签: html css

这仅在CSS中可行吗?我无权访问HTML或JS。我需要选择第二个匹配的选择器,而不是元素。

此操作在页面中重复了两次,但我找不到仅更改第二个元素的样式的方法。

.testimonials .testimonials-content .cover-component-slide{
    /* Change the second one */
}

2 个答案:

答案 0 :(得分:0)

尝试一下:

.testimonials:nth-child(2) .testimonials-content .cover-component-slide{
 ......
}

  .testimonials .testimonials-content .cover-component-slide:nth-child(2){
     ......
    }

答案 1 :(得分:0)

.msg:nth-of-type(2) {
    color: red;
}
<h1 class="msg">Hello World One</h1>
<h1 class="msg">Hello World Two</h1>