【发布时间】:2020-06-27 04:57:16
【问题描述】:
您好,我想为每个 4、5、6 元素应用一个类,并在之后继续重复。
HTML
<div class="parent-div">
<div [ngClass]="{'child-div3' : i > 4 }" class="child-div1">
<div class="arrow-right"></div>
</div>
<div class="child-div2">
<img class="object-fit_contain" [src]="deal.image">
</div>
</div>
CSS
.child-div1 {
margin: none !important;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 50%;
background: white;
z-index: 2;
}
.child-div3 {
margin: none !important;
position: absolute;
top: 0;
right: 0;
height: 100%;
width: 50%;
background: rgb(236, 147, 29);
z-index: 1;
}
我该怎么做?
编辑:
这是 Stackblitz 代码
https://stackblitz.com/edit/angular-ivy-itn1pc
谢谢。
【问题讨论】:
-
i 变量从何而来?应该放完整的代码
-
是的,放置TS文件
-
你能创建一个stackblitz吗
-
添加了 stackblitz 代码。但是,@Dewanshu 提供的以下代码确实有效,但我还需要它只选择每 4、5、6 个元素然后重复,所以我需要它选择 10、11、12 和 15、16、17 和很快。假设第一个数字是 1 而不是 0。