我有这段代码:
for i in (1..5)
div:nth-child({i})::after
content \'i*i\'
for i in (6..10)
div:nth-child({i})::after
ij = (i - 5)
content \'(ij*ij)\'
for i in (1..10)
div:nth-child({i})
ij = (i - 5)
if i >= 6
height ij * ij px
else
height i * i px
哪个输出:
但是我需要它在25时反转,所以它会:
1 4 9 16 25 25 16 9 4 1
不确定怎么做?
答案 0 :(得分:1)
更改计算ij的方式,从 ij =(i - 5) 改为 ij = 11 - i 强>
for i in (1..5)
div:nth-child({i})::after
content \'i*i\'
for i in (6..10)
div:nth-child({i})::after
ij = 11-i
content \'(ij*ij)\'
for i in (1..10)
div:nth-child({i})
ij = 11-i
if i >= 6
height ij * ij px
else
height i * i px
答案 1 :(得分:0)
var irt=1;
for(i=0;(i<10 && irt>0) || (i>0 && irt<0) ;i+=irt){
if(i==5){//this is where it well bi reversed
irt=-1;
}
//do whatever you want to do here
}