I am currently working on writing CSS for dynamically generated classes. I have set up the classes using ngFor as shown below:
<div style="max-height: 450px;" *ngFor="let item of data; let i = index" class="card{{i + 1}}">
.....
</div>
Now, I am in the process of styling these dynamic classes with CSS rules like this:
@media (min-width: 1399px) {
.card2,
.card6 {
padding-left: 0px;
padding-right: 0px;
}
.card3,
.card7 {
padding-right: 0px;
}
}
@media (min-width: 576px) and (max-width: 768px) {
.card2,
.card4,
.card6 {
padding-left: 0px;
}
}
As the number of divs may exceed 20, I am looking for a more efficient way to define these CSS rules without having to list each card individually. Is there a shorter method like using card(n+1) {....}?