클래스의 첫 번째 집합 만 선택하고 CSS를 적용하는 방법을 알아 내려고합니다. 코드에서 CSS - 첫 번째 클래스 집합 만 선택하십시오.
I 클래스와 DIV 년대의 첫 번째 집합에 색상을 적용하기 위해 노력하고있어 아래 .item<div class="field-items">
<div class="item">This text should be red</div>
<div class="item">This text should be red</div>
<div class="field-items">
<div class="item">This text should NOT be red</div>
<div class="item">This text should NOT be red</div>
<div class="item">This text should NOT be red</div>
<div class="item">This text should NOT be red</div>
</div>
<div class="item">This text should be red</div>
<div class="item">This text should be red</div>
</div>
문제는 .item DIV 년대의 두 번째 세트는 점이다 또한 색깔을 얻는 : 빨강; css. nth-child, : nth-of-type,>, + 등의 셀렉터를 가지고 놀았지만 어떻게해야하는지 알 수 없습니다.
제가 지금 생각해 볼 수있는 가장 좋은 점은 두 번째 세트의 CSS를 무시하는 것입니다.
.item {
color: #cc3333;
}
.item .item {
color: #000;
}
도움을 주시면 감사하겠습니다.
를 추가하지 않고 CSS입니다'.item'이 내부의 어느 것과도 일치하지 않을 .item'내부'.field-items' 실제로 아이이기 때문에 당신이 .item's 외부 '.field-items' 중 하나입니다. 아마도'.field-items .field-items .item'을 의미했을 것입니다. – BoltClock