LESS - 在字符串中使用nth-child变量

10 css-selectors less

当然有一种方法可以在LESS中重写以下内容?

#bg-slider{

li:nth-child(1){
    background:url('../images/bg1.jpg');
}

li:nth-child(2){
    background:url('../images/bg2.jpg');
}

li:nth-child(3){
    background:url('../images/bg3.jpg');
}

}
Run Code Online (Sandbox Code Playgroud)

我试过了:

.bg-image (@slide) {
  background:url('../images/bg@{slide}.jpg');
}

#bg-slider{
li:nth-child(n){
    .bg-image(n);
}
}
Run Code Online (Sandbox Code Playgroud)

但这只是给所有李的'../images/bgn.jpg'.

sev*_*max 16

#bg-slider {
    li {
        .bkg(1);
        .bkg(2);
        .bkg(3);
    }

    .bkg(@i) {
        &:nth-child(@{i}) {
            background: url('../images/bg@{i}.jpg');
        }
    }
}
Run Code Online (Sandbox Code Playgroud)