I am working with a bootstrap accordion and I want to customize the color of the h4
titles for the elements within the DOM. My goal is to have distinct colors for the first 4 elements, then repeat those colors.
.my-platform-title:nth-child(2n+1) {
color: #1a9e49;
}
.my-platform-title:nth-child(2n) {
color: #7bc9c8 !important;
}
.my-platform-title:nth-child(3n) {
color: #fd8d6e !important;
}
.my-platform-title:nth-child(4n) {
color: #bf6da6 !important;
}
<div class="panel-heading my-panel-heading" role="tab" id="platform1">
<h4 class="panel-title my-panel-title my-platform-title">
<a role="button" data-toggle="collapse" data-parent="#platforms" href="#platform-collapse1" aria-expanded="false" aria-controls="platform-collapse1">
<span class="fa fa-plus-square-o text-success"></span> Platform 1
</a>
</h4>
</div>
<div class="panel-heading my-panel-heading" role="tab" id="platform<2">
<h4 class="panel-title my-panel-title my-platform-title">
<a role="button" data-toggle="collapse" data-parent="#platforms" href="#platform-collapse<2" aria-expanded="false" aria-controls="platform-collapse<2">
<span class="fa fa-plus-square-o text-success"></span> Platform 2
</a>
</h4>
</div>
<div class="panel-heading my-panel-heading" role="tab" id="platform3">
<h4 class="panel-title my-panel-title my-platform-title">
<a role="button" data-toggle="collapse" data-parent="#platforms" href="#platform-collapse3" aria-expanded="false" aria-controls="platform-collapse3">
<span class="fa fa-plus-square-o text-success"></span> Platform 3
</a>
</h4>
</div>
<div class="panel-heading my-panel-heading" role="tab" id="platform4">
<h4 class="panel-title my-platform-title my-platform-title">
<a role="button" data-toggle="collapse" data-parent="#platforms" href="#platform-collapse4" aria-expanded="false" aria-controls="platform-collapse4">
<span class="fa fa-plus-square-o text-success"></span> Platform 4
</a>
</h4>
</div>
The issue I'm encountering is that only the first color rule is being applied, while the others are being ignored.